home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_300 / 398_01 / asmlnk.doc < prev    next >
Encoding:
Text File  |  1993-08-06  |  162.9 KB  |  4,774 lines

  1.  
  2.  
  3.          
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.                                 ASxxxx Assemblers
  27.  
  28.  
  29.                                        and
  30.  
  31.  
  32.                             ASLINK Relocating Linker
  33.  
  34.  
  35.         CHAPTER 1  THE ASSEMBLER                                     1-1 
  36.           1.1     THE ASXXXX ASSEMBLERS                              1-1 
  37.           1.1.1     Assembly Pass 1                                  1-2 
  38.           1.1.2     Assembly Pass 2                                  1-2 
  39.           1.1.3     Assembly Pass 3                                  1-2 
  40.           1.2     SOURCE PROGRAM FORMAT                              1-3 
  41.           1.2.1     Statement Format                                 1-3 
  42.           1.2.1.1     Label Field                                    1-3 
  43.           1.2.1.2     Operator Field                                 1-5 
  44.           1.2.1.3     Operand Field                                  1-5 
  45.           1.2.1.4     Comment Field                                  1-6 
  46.           1.3     SYMBOLS AND EXPRESSIONS                            1-6 
  47.           1.3.1     Character Set                                    1-6 
  48.           1.3.2     User-Defined Symbols                            1-10 
  49.           1.3.3     Local Symbols                                   1-11 
  50.           1.3.4     Current Location Counter                        1-12 
  51.           1.3.5     Numbers                                         1-14 
  52.           1.3.6     Terms                                           1-14 
  53.           1.3.7     Expressions                                     1-15 
  54.           1.4     GENERAL ASSEMBLER DIRECTIVES                      1-16 
  55.           1.4.1     .module Directive                               1-16 
  56.           1.4.2     .title Directive                                1-17 
  57.           1.4.3     .sbttl Directive                                1-17 
  58.           1.4.4     .page Directive                                 1-17 
  59.           1.4.5     .byte and .db Directives                        1-17 
  60.           1.4.6     .word and .dw Directives                        1-18 
  61.           1.4.7     .blkb, .blkw, and .ds Directives                1-18 
  62.           1.4.8     .ascii Directive                                1-18 
  63.           1.4.9     .asciz Directive                                1-19 
  64.           1.4.10    .radix Directive                                1-19 
  65.           1.4.11    .even Directive                                 1-20 
  66.           1.4.12    .odd Directive                                  1-20 
  67.           1.4.13    .area Directive                                 1-20 
  68.           1.4.14    .org Directive                                  1-22 
  69.           1.4.15    .globl Directive                                1-22 
  70.           1.4.16    .if, .else, and .endif Directives               1-23 
  71.           1.4.17    .include Directive                              1-24 
  72.           1.4.18    .setdp Directive                                1-24 
  73.           1.5     INVOKING ASXXXX                                   1-26 
  74.           1.6     ERRORS                                            1-27 
  75.           1.7     LISTING FILE                                      1-28 
  76.           1.8     SYMBOL TABLE FILE                                 1-30 
  77.           1.9     OBJECT FILE                                       1-30 
  78.  
  79.         CHAPTER 2  THE LINKER                                        2-1 
  80.           2.1     ASLINK RELOCATING LINKER                           2-1 
  81.           2.2     INVOKING ASLINK                                    2-2 
  82.           2.3     ASLINK PROCESSING                                  2-3 
  83.           2.4     LINKER INPUT FORMAT                                2-4 
  84.           2.4.1     Object Module Format                             2-5 
  85.           2.4.2     Header Line                                      2-5 
  86.           2.4.3     Module Line                                      2-5 
  87.           2.4.4     Symbol Line                                      2-5 
  88.           2.4.5     Area Line                                        2-6 
  89.           2.4.6     T Line                                           2-6 
  90.           2.4.7     R Line                                           2-6 
  91.  
  92.  
  93.                                                                  Page ii
  94.         
  95.  
  96.  
  97.           2.4.8     P Line                                           2-7 
  98.           2.5     LINKER ERROR MESSAGES                              2-7 
  99.  
  100.         CHAPTER 3  BUILDING ASXXXX AND ASLINK                        3-1 
  101.           3.1     BUILDING AN ASSEMBLER                              3-1 
  102.           3.2     BUILDING ASLINK                                    3-2 
  103.  
  104.         APPENDIX A  AS6800 ASSEMBLER                                 A-1 
  105.           A.1     6800 REGISTER SET                                  A-1 
  106.           A.2     6800 INSTRUCTION SET                               A-1 
  107.           A.2.1     Inherent Instructions                            A-2 
  108.           A.2.2     Branch Instructions                              A-2 
  109.           A.2.3     Single Operand Instructions                      A-3 
  110.           A.2.4     Double Operand Instructions                      A-4 
  111.           A.2.5     Jump and Jump to Subroutine Instructions         A-4 
  112.           A.2.6     Long Register Instructions                       A-5 
  113.  
  114.         APPENDIX B  AS6801 ASSEMBLER                                 B-1 
  115.           B.1     .hd6303 DIRECTIVE                                  B-1 
  116.           B.2     6801 REGISTER SET                                  B-1 
  117.           B.3     6801 INSTRUCTION SET                               B-1 
  118.           B.3.1     Inherent Instructions                            B-2 
  119.           B.3.2     Branch Instructions                              B-2 
  120.           B.3.3     Single Operand Instructions                      B-3 
  121.           B.3.4     Double Operand Instructions                      B-4 
  122.           B.3.5     Jump and Jump to Subroutine Instructions         B-5 
  123.           B.3.6     Long Register Instructions                       B-5 
  124.           B.3.7     6303 Specific Instructions                       B-5 
  125.  
  126.         APPENDIX C  AS6804 ASSEMBLER                                 C-1 
  127.           C.1     6804 REGISTER SET                                  C-1 
  128.           C.2     6804 INSTRUCTION SET                               C-1 
  129.           C.2.1     Inherent Instructions                            C-2 
  130.           C.2.2     Branch Instructions                              C-2 
  131.           C.2.3     Single Operand Instructions                      C-2 
  132.           C.2.4     Jump and Jump to Subroutine Instructions         C-2 
  133.           C.2.5     Bit Test Instructions                            C-2 
  134.           C.2.6     Load Immediate data Instruction                  C-3 
  135.           C.2.7     6804 Derived Instructions                        C-3 
  136.  
  137.         APPENDIX D  AS6805 ASSEMBLER                                 D-1 
  138.           D.1     6805 REGISTER SET                                  D-1 
  139.           D.2     6805 INSTRUCTION SET                               D-1 
  140.           D.2.1     Control Instructions                             D-2 
  141.           D.2.2     Bit Manipulation Instructions                    D-2 
  142.           D.2.3     Branch Instructions                              D-2 
  143.           D.2.4     Read-Modify-Write Instructions                   D-3 
  144.           D.2.5     Register\Memory Instructions                     D-3 
  145.           D.2.6     Jump and Jump to Subroutine Instructions         D-4 
  146.  
  147.         APPENDIX E  AS68HC08 ASSEMBLER                               E-1 
  148.           E.1     68HC08 REGISTER SET                                E-1 
  149.  
  150.  
  151.                                                                 Page iii
  152.         
  153.  
  154.  
  155.           E.2     68HC08 INSTRUCTION SET                             E-1 
  156.           E.2.1     Control Instructions                             E-2 
  157.           E.2.2     Bit Manipulation Instructions                    E-2 
  158.           E.2.3     Branch Instructions                              E-3 
  159.           E.2.4     Complex Branch Instructions                      E-3 
  160.           E.2.5     Read-Modify-Write Instructions                   E-4 
  161.           E.2.6     Register\Memory Instructions                     E-5 
  162.           E.2.7     Double Operand Move Instruction                  E-5 
  163.           E.2.8     16-Bit <H:X> Index Register Instructions         E-5 
  164.           E.2.9     Jump and Jump to Subroutine Instructions         E-5 
  165.  
  166.         APPENDIX F  AS6809 ASSEMBLER                                 F-1 
  167.           F.1     6809 REGISTER SET                                  F-1 
  168.           F.2     6809 INSTRUCTION SET                               F-1 
  169.           F.2.1     Inherent Instructions                            F-3 
  170.           F.2.2     Short Branch Instructions                        F-3 
  171.           F.2.3     Long Branch Instructions                         F-3 
  172.           F.2.4     Single Operand Instructions                      F-4 
  173.           F.2.5     Double Operand Instructions                      F-5 
  174.           F.2.6     D-register Instructions                          F-5 
  175.           F.2.7     Index/Stack Register Instructions                F-5 
  176.           F.2.8     Jump and Jump to Subroutine Instructions         F-6 
  177.           F.2.9     Register - Register Instructions                 F-6 
  178.           F.2.10    Condition Code Register Instructions             F-6 
  179.           F.2.11    6800 Compatibility Instructions                  F-6 
  180.  
  181.         APPENDIX G  AS6811 ASSEMBLER                                 G-1 
  182.           G.1     6811 REGISTER SET                                  G-1 
  183.           G.2     6811 INSTRUCTION SET                               G-1 
  184.           G.2.1     Inherent Instructions                            G-2 
  185.           G.2.2     Branch Instructions                              G-2 
  186.           G.2.3     Single Operand Instructions                      G-3 
  187.           G.2.4     Double Operand Instructions                      G-4 
  188.           G.2.5     Bit Manupulation Instructions                    G-4 
  189.           G.2.6     Jump and Jump to Subroutine Instructions         G-5 
  190.           G.2.7     Long Register Instructions                       G-5 
  191.  
  192.         APPENDIX H  AS6816 ASSEMBLER                                 H-1 
  193.           H.1     6816 REGISTER SET                                  H-1 
  194.           H.2     6816 INSTRUCTION SET                               H-1 
  195.           H.2.1     Inherent Instructions                            H-2 
  196.           H.2.2     Push/Pull Multiple Register Instructions         H-3 
  197.           H.2.3     Short Branch Instructions                        H-3 
  198.           H.2.4     Long Branch Instructions                         H-3 
  199.           H.2.5     Bit Manipulation Instructions                    H-3 
  200.           H.2.6     Single Operand Instructions                      H-4 
  201.           H.2.7     Double Operand Instructions                      H-5 
  202.           H.2.8     Index/Stack Register Instructions                H-5 
  203.           H.2.9     Jump and Jump to Subroutine Instructions         H-6 
  204.           H.2.10    Condition Code Register Instructions             H-6 
  205.           H.2.11    Multiply and Accumulate Instructions             H-6 
  206.  
  207.  
  208.  
  209.                                                                  Page iv
  210.         
  211.  
  212.  
  213.         APPENDIX I  AS8085 ASSEMBLER                                 I-1 
  214.           I.1     8085 REGISTER SET                                  I-1 
  215.           I.2     8085 INSTRUCTION SET                               I-1 
  216.           I.2.1     Inherent Instructions                            I-2 
  217.           I.2.2     Register/Memory/Immediate Instructions           I-2 
  218.           I.2.3     Call and Return Instructions                     I-2 
  219.           I.2.4     Jump Instructions                                I-2 
  220.           I.2.5     Input/Output/Reset Instructions                  I-3 
  221.           I.2.6     Move Instructions                                I-3 
  222.           I.2.7     Other Instructions                               I-3 
  223.  
  224.         APPENDIX J  ASZ80 ASSEMBLER                                  J-1 
  225.           J.1     .hd64 DIRECTIVE                                    J-1 
  226.           J.2     Z80 REGISTER SET AND CONDITIONS                    J-1 
  227.           J.3     Z80 INSTRUCTION SET                                J-2 
  228.           J.3.1     Inherent Instructions                            J-3 
  229.           J.3.2     Implicit Operand Instructions                    J-3 
  230.           J.3.3     Load Instruction                                 J-4 
  231.           J.3.4     Call/Return Instructions                         J-4 
  232.           J.3.5     Jump and Jump to Subroutine Instructions         J-4 
  233.           J.3.6     Bit Manipulation Instructions                    J-5 
  234.           J.3.7     Interrupt Mode and Reset Instructions            J-5 
  235.           J.3.8     Input and Output Instructions                    J-5 
  236.           J.3.9     Register Pair Instructions                       J-5 
  237.           J.3.10    HD64180 Specific Instructions                    J-6 
  238.  
  239.  
  240.                                                                   Page v
  241.         
  242.  
  243.  
  244.          
  245.  
  246.  
  247.  
  248.  
  249.  
  250.                                   P R E F A C E
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.            The  ASxxxx  assemblers  were  written following the style of
  258.         several cross assemblers found in the Digital Equipment Corpora-
  259.         tion  Users  Society  (DECUS)  distribution of the C programming
  260.         language.  The DECUS code was provided with no documentation  as
  261.         to  the  input  syntax  or the output format.  Study of the code
  262.         revealed that the unknown author of the code  had  attempted  to
  263.         formulate  an assembler with attributes similiar to those of the
  264.         PDP-11 MACRO assembler (without macro's).  The  incomplete  code
  265.         from  the  DECUS C distribution has been largely rewritten, only
  266.         the program structure, and C source  file  organization  remains
  267.         relatively  unchanged.   However, I wish to thank the author for
  268.         his contribution to this set of assemblers.  
  269.  
  270.            The  ASLINK  program was written as a companion to the ASxxxx
  271.         assemblers, its design and implementation was not  derived  from
  272.         any other work.  
  273.  
  274.            The  ASxxxx  assemblers  and the ASLINK relocating linker are
  275.         placed in the Public Domain.   Publication  or  distribution  of
  276.         these programs for non-commercial use is hereby granted with the
  277.         stipulation that the  copyright  notice  be  included  with  all
  278.         copies.  
  279.  
  280.            I  would  greatly  appreciate  receiving  the  details of any
  281.         changes, additions, or errors pertaining to these  programs  and
  282.         will  attempt  to  incorporate  any  fixes  or  generally useful
  283.         changes in a future update to these programs.  
  284.  
  285.  
  286.  
  287.  
  288.                        Alan R.  Baldwin 
  289.                        Kent State University 
  290.                        Physics Department 
  291.                        Kent, Ohio 44242 
  292.  
  293.  
  294.                                                                  Page vi
  295.         
  296.  
  297.  
  298.          
  299.  
  300.  
  301.  
  302.  
  303.  
  304.                         C H A N G E S   I N   V 0 1 . 5 0
  305.  
  306.  
  307.  
  308.  
  309.  
  310.  
  311.            The  ASxxxx  assembler  and  linker have been updated to move
  312.         byte index, direct page  mode,  and  byte  pc  relative  address
  313.         checking  from the assembler to the linker.  This change has al-
  314.         lowed the following enhancements:  
  315.  
  316.              1.  The  .setdp  directive  now has a common format for all
  317.                  AS68xx assemblers.  
  318.  
  319.              2.  Direct  page  variables  may be externally defined with
  320.                  their addresses resolved at link time.  
  321.  
  322.              3.  Byte  index  offsets  may  be  external  references and
  323.                  resolved at link time.  
  324.  
  325.              4.  Byte  pc  relative  instructions  (i.e.   branches) may
  326.                  reference external labels or labels in other areas.  
  327.  
  328.  
  329.            The  ASxxxx  assemblers  (using  the  -f  or  -ff option) can
  330.         generate a listing file which flags the data that will be  relo-
  331.         cated by the linker.  
  332.  
  333.            The  REL file format now has an additional directive for pag-
  334.         ing information and has additional flags for  page0,  page,  and
  335.         unsigned  byte  formats.   The new linker is compatible with the
  336.         first version of the ASxxxx assemblers.  
  337.  
  338.            The  remaining changes are related to non-portable code found
  339.         while porting the assemblers to a motorola 68030 system.  
  340.  
  341.  
  342.  
  343.  
  344.  
  345.  
  346.  
  347.  
  348.  
  349.  
  350.  
  351.  
  352.  
  353.  
  354.                                     CHAPTER 1
  355.  
  356.                                   THE ASSEMBLER
  357.  
  358.  
  359.  
  360.  
  361.  
  362.         1.1  THE ASXXXX ASSEMBLERS 
  363.  
  364.  
  365.            The  ASxxxx  assemblers are a series of microprocessor assem-
  366.         blers written in the C programming language.  Each assembler has
  367.         a device specific section which includes:  
  368.  
  369.              1.  device  description, byte order, and file extension in-
  370.                  formation 
  371.  
  372.              2.  a  table  of  the assembler general directives, special
  373.                  device directives, assembler mnemonics  and  associated
  374.                  operation codes 
  375.  
  376.              3.  machine specific code for processing the device mnemon-
  377.                  ics, addressing modes, and special directives 
  378.  
  379.         The device specific information is detailed in the appendices.  
  380.  
  381.            The assemblers have a common device independent section which
  382.         handles the details of file input/output, symbol  table  genera-
  383.         tion,  program/data  areas,  expression  analysis, and assembler
  384.         directive processing.  
  385.  
  386.         The assemblers provide the following features:  
  387.  
  388.              1.  Command string control of assembly functions 
  389.  
  390.              2.  Alphabetized, formatted symbol table listing 
  391.  
  392.              3.  Relocatable object modules 
  393.  
  394.              4.  Global symbols for linking object modules 
  395.  
  396.              5.  Conditional assembly directives 
  397.  
  398.  
  399.  
  400.         THE ASSEMBLER                                           PAGE 1-2
  401.         THE ASXXXX ASSEMBLERS
  402.  
  403.  
  404.              6.  Program sectioning directives 
  405.  
  406.  
  407.            ASxxxx assembles one or more source files into a single relo-
  408.         catable ascii object file.  The output of the ASxxxx  assemblers
  409.         consists of an ascii relocatable object file(*.rel), an assembly
  410.         listing file(*.lst), and a symbol file(*.sym).  
  411.  
  412.  
  413.         1.1.1  Assembly Pass 1 
  414.  
  415.  
  416.            During  pass  1, ASxxxx opens all source files and performs a
  417.         rudimenatry assembly of each source statement.  During this pro-
  418.         cess  all symbol tables are built, program sections defined, and
  419.         number of bytes for each assembled source line is estimated.  
  420.  
  421.            At the end of pass 1 all undefined symbols may be made global
  422.         (external) using the ASxxxx switch -g, otherwise undefined  sym-
  423.         bols will be flagged as errors during succeeding passes.  
  424.  
  425.  
  426.         1.1.2  Assembly Pass 2 
  427.  
  428.  
  429.            During  pass  2  the ASxxxx assembler resolves forward refer-
  430.         ences and determines the number  of  bytes  for  each  assembled
  431.         line.   The  number  of bytes used by a particular assembler in-
  432.         struction may depend upon the addressing mode, whether  the  in-
  433.         struction allows multiple forms based upon the relative distance
  434.         to the addressed location, or other factors.   Pass  2  resolves
  435.         these cases and determines the address of all symbols.  
  436.  
  437.  
  438.         1.1.3  Assembly Pass 3 
  439.  
  440.  
  441.            Pass 3 by the assembler generates the listing file, the relo-
  442.         catable output file, and the symbol tables.  Also during pass  3
  443.         the errors will be reported.  
  444.  
  445.            The  relocatable object file is an ascii file containing sym-
  446.         bol references and definitions, program  area  definitions,  and
  447.         the  relocatable assembled code, the linker ASLINK will use this
  448.         information to generate an absolute load file (Motorola or Intel
  449.         formats).  
  450.  
  451.  
  452.  
  453.  
  454.         THE ASSEMBLER                                           PAGE 1-3
  455.         SOURCE PROGRAM FORMAT
  456.  
  457.  
  458.         1.2  SOURCE PROGRAM FORMAT 
  459.  
  460.  
  461.  
  462.         1.2.1  Statement Format 
  463.  
  464.  
  465.            A source program is composed of assembly-language statements.
  466.         Each statement must be completed on one line.  A line  may  con-
  467.         tain a maximum of 128 characters, longer lines are truncated and
  468.         lost.  
  469.  
  470.            An  ASxxxx  assembler  statement  may  have  as  many as four
  471.         fields.  These fields are identified by their order  within  the
  472.         statement  and/or  by separating characters between fields.  The
  473.         general format of the ASxxxx statement is:  
  474.  
  475.               [label:]  Operator        Operand         [;Comment(s)] 
  476.  
  477.            The  label and comment fields are optional.  The operator and
  478.         operand fields are interdependent.  The operator field may be an
  479.         assembler  directive or an assembly mnemonic.  The operand field
  480.         may be optional or required as defined in  the  context  of  the
  481.         operator.  
  482.  
  483.            ASxxxx  interprets  and  processes source statements one at a
  484.         time.  Each statement causes a particular operation to  be  per-
  485.         formed.  
  486.  
  487.  
  488.         1.2.1.1  Label Field  - 
  489.  
  490.            A  label is a user-defined symbol which is assigned the value
  491.         of the current location counter and entered into  the  user  de-
  492.         fined  symbol  table.   The  current location counter is used by
  493.         ASxxxx to assign memory addresses to the source  program  state-
  494.         ments as they are encountered during the assembly process.  Thus
  495.         a label is a means  of  symbolically  referring  to  a  specific
  496.         statement.  
  497.  
  498.            When  a program section is absolute, the value of the current
  499.         location counter is absolute;  its value references an  absolute
  500.         memory  address.   Similarly, when a program section is relocat-
  501.         able, the value of the current location counter is  relocatable.
  502.         A  relocation  bias  calculated at link time is added to the ap-
  503.         parent value of the current location counter  to  establish  its
  504.         effective  absolute  address  at  execution time.  (The user can
  505.         also force the linker to relocate sections defined as  absolute.
  506.         This may be required under special circumstances.) 
  507.  
  508.            If  present,  a  label  must  be  the first field in a source
  509.         statement and must be terminated by a colon (:).   For  example,
  510.  
  511.  
  512.         THE ASSEMBLER                                           PAGE 1-4
  513.         SOURCE PROGRAM FORMAT
  514.  
  515.  
  516.         if  the  value  of  the  current  location  counter  is absolute
  517.         01F0(H), the statement:  
  518.  
  519.               abcd:     nop 
  520.  
  521.         assigns  the  value  01F0(H) to the label abcd.  If the location
  522.         counter value were relocatable, the final value of abcd would be
  523.         01F0(H)+K, where K represents the relocation bias of the program
  524.         section, as calculated by the linker at link time.  
  525.  
  526.            More  than  one label may appear within a single label field.
  527.         Each label so specified is assigned the same address value.  For
  528.         example,  if  the  value  of  the  current  location  counter is
  529.         1FF0(H), the multiple labels in the following statement are each
  530.         assigned the value 1FF0(H):  
  531.  
  532.               abcd:     aq:     $abc:   nop 
  533.  
  534.            Multiple labels may also appear on successive lines.  For ex-
  535.         ample, the statements 
  536.  
  537.               abcd:  
  538.               aq:  
  539.               $abc:     nop 
  540.  
  541.         likewise  cause  the  same value to be assigned to all three la-
  542.         bels.  
  543.  
  544.            A  double  colon  (::)  defines the label as a global symbol.
  545.         For example, the statement 
  546.  
  547.               abcd::    nop 
  548.  
  549.         establishes the label abcd as a global symbol.  The distinguish-
  550.         ing attribute of a global symbol is that it  can  be  referenced
  551.         from  within an object module other than the module in which the
  552.         symbol is defined.  References to this label  in  other  modules
  553.         are  resolved when the modules are linked as a composite execut-
  554.         able image.  
  555.  
  556.         The legal characters for defining labels are:  
  557.  
  558.                 A through Z 
  559.                 a through z 
  560.                 0 through 9 
  561.                 . (Period) 
  562.                 $ (Dollar sign) 
  563.                 _ (underscore) 
  564.  
  565.            A  label may be any length, however, only the first eight (8)
  566.         characters are significant and, therefore must be  unique  among
  567.         all   labels  in  the  source  program  (not  necessarily  among
  568.  
  569.  
  570.         THE ASSEMBLER                                           PAGE 1-5
  571.         SOURCE PROGRAM FORMAT
  572.  
  573.  
  574.         separately compiled modules).  An error code(s) (m or p) will be
  575.         generated  in the assembly listing if the first eight characters
  576.         in two or more labels are the same.  The m code is caused by the
  577.         redeclaration  of  the symbol or its reference by another state-
  578.         ment.  The p code is generated because the symbols  location  is
  579.         changing on each pass through the source file.  
  580.  
  581.            The  label  must  not  start with the characters 0-9, as this
  582.         designates a local symbol with special attributes described in a
  583.         later section.  
  584.  
  585.  
  586.         1.2.1.2  Operator Field  - 
  587.  
  588.            The  operator field specifies the action to be performed.  It
  589.         may consist of an instruction mnemonic (op code) or an assembler
  590.         directive.  
  591.  
  592.            When  the  operator is an instruction mnemonic, a machine in-
  593.         struction is generated and the assembler evaluates the addresses
  594.         of  the operands which follow.  When the operator is a directive
  595.         ASxxxx performs certain control actions or processing operations
  596.         during assembly of the source program.  
  597.  
  598.            Leading  and  trailing  spaces  or tabs in the operator field
  599.         have no significance;  such characters serve  only  to  separate
  600.         the operator field from the preceeding and following fields.  
  601.  
  602.            An operator is terminated by a space, tab or end of line.  
  603.  
  604.  
  605.         1.2.1.3  Operand Field  - 
  606.  
  607.            When  the  operator is an instruction mnemonic (op code), the
  608.         operand  field  contains  program  variables  that  are  to   be
  609.         evaluated/manipulated by the operator.  
  610.  
  611.            Operands  may  be  expressions  or  symbols, depending on the
  612.         operator.  Multiple expressions used in the operand  fields  may
  613.         be  separated  by a comma.  An operand should be preceeded by an
  614.         operator field;  if it is not, the statement will give an  error
  615.         (q  or  o).   All  operands  following instruction mnemonics are
  616.         treated as expressions.  
  617.  
  618.            The operand field is terminated by a semicolon when the field
  619.         is followed  by  a  comment.   For  example,  in  the  following
  620.         statement:  
  621.  
  622.               label:    lda     abcd,x          ;Comment field 
  623.  
  624.         the  tab  between lda and abcd terminates the operator field and
  625.         defines the beginning of the operand field;  a  comma  separates
  626.  
  627.  
  628.         THE ASSEMBLER                                           PAGE 1-6
  629.         SOURCE PROGRAM FORMAT
  630.  
  631.  
  632.         the operands abcd and x;  and a semicolon terminates the operand
  633.         field and defines the beginning of the comment field.   When  no
  634.         comment  field  follows,  the operand field is terminated by the
  635.         end of the source line.  
  636.  
  637.  
  638.         1.2.1.4  Comment Field  - 
  639.  
  640.            The comment field begins with a semicolon and extends through
  641.         the end of the line.  This field is optional and may contain any
  642.         7-bit ascii character except null.  
  643.  
  644.            Comments  do not affect assembly processing or program execu-
  645.         tion.  
  646.  
  647.  
  648.         1.3  SYMBOLS AND EXPRESSIONS 
  649.  
  650.  
  651.            This  section  describes the generic components of the ASxxxx
  652.         assemblers:  the character set, the conventions observed in con-
  653.         structing  symbols,  and  the use of numbers, operators, and ex-
  654.         pressions.  
  655.  
  656.  
  657.         1.3.1  Character Set 
  658.  
  659.  
  660.            The following characters are legal in ASxxxx source programs: 
  661.  
  662.              1.  The  letters  A  through Z.  Both upper- and lower-case
  663.                  letters are acceptable.  The assemblers are case sensi-
  664.                  tive,  i.e.  ABCD and abcd are different symbols.  (The
  665.                  assemblers can be made case insensitive by  recompiling
  666.                  with the appropriate switches.) 
  667.  
  668.              2.  The digits 0 through 9 
  669.  
  670.              3.  The  characters . (period), $ (dollar sign), and _ (un-
  671.                  derscore).  
  672.  
  673.              4.  The special characters listed in Tables 1 through 6.  
  674.  
  675.  
  676.            Tables  1  through  6  describe  the various ASxxxx label and
  677.         field terminators, assignment operators, operand separators, as-
  678.         sembly, unary, binary, and radix operators.  
  679.  
  680.  
  681.         THE ASSEMBLER                                           PAGE 1-7
  682.         SYMBOLS AND EXPRESSIONS
  683.  
  684.  
  685.         Table 1         Label Terminators and Assignment Operators 
  686.         ---------------------------------------------------------------- 
  687.  
  688.                 :   Colon               Label terminator.  
  689.  
  690.                 ::  Double colon        Label  Terminator;   defines the
  691.                                         label as a global label.  
  692.  
  693.                 =   Equal sign          Direct assignment operator.  
  694.  
  695.                 ==  Double equal        Direct assignment operator;  
  696.                     sign                defines  the  symbol as a global
  697.                                         symbol.  
  698.  
  699.         ---------------------------------------------------------------- 
  700.  
  701.  
  702.  
  703.  
  704.  
  705.         Table 2         Field Terminators and Operand Separators 
  706.         ---------------------------------------------------------------- 
  707.  
  708.                     Tab                 Item or field terminator.  
  709.  
  710.                     Space               Item or field terminator.  
  711.  
  712.                 ,   Comma               Operand field separator.  
  713.  
  714.                 ;   Semicolon           Comment field indicator.  
  715.  
  716.         ---------------------------------------------------------------- 
  717.  
  718.  
  719.  
  720.  
  721.  
  722.         Table 3         Assembler Operators 
  723.         ---------------------------------------------------------------- 
  724.  
  725.                 #   Number sign         Immediate expression indicator. 
  726.  
  727.                 .   Period              Current location counter.  
  728.  
  729.                 (   Left parenthesis    Expression delimiter.  
  730.  
  731.                 )   Right parenthesis   Expression delimeter.  
  732.  
  733.         ---------------------------------------------------------------- 
  734.  
  735.  
  736.         THE ASSEMBLER                                           PAGE 1-8
  737.         SYMBOLS AND EXPRESSIONS
  738.  
  739.  
  740.  
  741.  
  742.  
  743.  
  744.  
  745.         Table 4         Unary Operators 
  746.         ---------------------------------------------------------------- 
  747.  
  748.                 <   Left bracket        <FEDC   Produces  the lower byte
  749.                                                 value of the expression.
  750.                                                 (DC) 
  751.  
  752.                 >   Right bracket       >FEDC   Produces  the upper byte
  753.                                                 value of the expression.
  754.                                                 (FE) 
  755.  
  756.                 +   Plus sign           +A      Positive value of A 
  757.  
  758.                 -   Minus sign          -A      Produces   the  negative
  759.                                                 (2's complement) of A.  
  760.  
  761.                 ~   Tilde               ~A      Produces the 1's comple-
  762.                                                 ment of A.  
  763.  
  764.                 '   Single quote        'D      Produces  the  value  of
  765.                                                 the character D.  
  766.  
  767.                 "   Double quote        "AB     Produces the double byte
  768.                                                 value for AB.  
  769.  
  770.                 \   Backslash           '\n     Unix style characters 
  771.                                                 \b, \f, \n, \r, \t 
  772.                                      or '\001   or octal byte values.  
  773.  
  774.         ---------------------------------------------------------------- 
  775.  
  776.  
  777.  
  778.  
  779.  
  780.  
  781.  
  782.         THE ASSEMBLER                                           PAGE 1-9
  783.         SYMBOLS AND EXPRESSIONS
  784.  
  785.  
  786.         Table 5         Binary Operators 
  787.         ---------------------------------------------------------------- 
  788.  
  789.                 <<  Double          0800 << 4   Produces the 4 bit 
  790.                     Left bracket                left-shifted   value  of
  791.                                                 0800.  (8000) 
  792.  
  793.                 >>  Double          0800 >> 4   Produces the 4 bit 
  794.                     Right bracket               right-shifted  value  of
  795.                                                 0800.  (0080) 
  796.  
  797.                 +   Plus sign       A + B       Arithmetic      Addition
  798.                                                 operator.  
  799.  
  800.                 -   Minus sign      A - B       Arithmetic   Subtraction
  801.                                                 operator.  
  802.  
  803.                 *   Asterisk        A * B       Arithmetic   Multiplica-
  804.                                                 tion operator.   (signed
  805.                                                 16-bit) 
  806.  
  807.                 /   Slash           A / B       Arithmetic      Division
  808.                                                 operator.        (signed
  809.                                                 16-bit quotient) 
  810.  
  811.                 &   Ampersand       A & B       Logical AND operator.  
  812.  
  813.                 |   Bar             A | B       Logical OR operator.  
  814.  
  815.                 %   Percent sign    A % B       Modulus operator.  
  816.                                                 (16-bit value) 
  817.  
  818.                 ^   Up arrow or     A ^ B       EXCLUSIVE OR operator.  
  819.                     circumflex 
  820.  
  821.         ---------------------------------------------------------------- 
  822.  
  823.  
  824.  
  825.  
  826.  
  827.  
  828.  
  829.         THE ASSEMBLER                                          PAGE 1-10
  830.         SYMBOLS AND EXPRESSIONS
  831.  
  832.  
  833.         Table 6         Temporary Radix Operators 
  834.         ---------------------------------------------------------------- 
  835.  
  836.                 0b, 0B                  Binary radix operator.  
  837.  
  838.                 0@, 0o, 0O, 0q, 0Q      Octal radix operator.  
  839.  
  840.                 0d, 0D                  Decimal radix operator.  
  841.  
  842.                 0h, 0H, 0x, 0X          Hexidecimal radix operator.  
  843.  
  844.  
  845.                 Potential  ambiguities arising from the use of 0b and 0d
  846.                 as temporary radix operators may be circumvented by pre-
  847.                 ceding  all  non-prefixed  hexidecimal  numbers with 00.
  848.                 Leading 0's are required in any  case  where  the  first
  849.                 hexidecimal  digit is abcdef as the assembler will treat
  850.                 the letter sequence as a label.  
  851.  
  852.         ---------------------------------------------------------------- 
  853.  
  854.  
  855.  
  856.  
  857.  
  858.  
  859.  
  860.         1.3.2  User-Defined Symbols 
  861.  
  862.  
  863.            User-defined  symbols are those symbols that are equated to a
  864.         specific value through a direct assignment statement  or  appear
  865.         as  labels.  These symbols are added to the User Symbol Table as
  866.         they are encountered during assembly.  
  867.  
  868.         The following rules govern the creation of user-defined symbols: 
  869.  
  870.              1.  Symbols  can  be  composed  of alphanumeric characters,
  871.                  dollar signs ($),  periods  (.),  and  underscores  (_)
  872.                  only.  
  873.  
  874.              2.  The  first  character  of a symbol must not be a number
  875.                  (except in the case of local symbols).  
  876.  
  877.              3.  The  first eight characters of a symbol must be unique.
  878.                  A symbol can be written  with  more  than  eight  legal
  879.                  characters, but the ninth and subsequent characters are
  880.                  ignored.  
  881.  
  882.              4.  Spaces and Tabs must not be embedded within a symbol.  
  883.  
  884.  
  885.  
  886.  
  887.         THE ASSEMBLER                                          PAGE 1-11
  888.         SYMBOLS AND EXPRESSIONS
  889.  
  890.  
  891.         1.3.3  Local Symbols 
  892.  
  893.  
  894.            Local  symbols are specially formatted symbols used as labels
  895.         within a block of coding that has been delimited as a local sym-
  896.         bol  block.   Local  symbols  are  of  the form n$, where n is a
  897.         decimal integer from 0 to 255,  inclusive.   Examples  of  local
  898.         symbols are:  
  899.  
  900.               1$ 
  901.               27$ 
  902.               138$ 
  903.               244$ 
  904.  
  905.            The  range  of  a local symbol block consists of those state-
  906.         ments between two normally constructed  symbolic  labels.   Note
  907.         that a statement of the form:  
  908.  
  909.               ALPHA = EXPRESSION 
  910.  
  911.         is a direct assignment statement but does not create a label and
  912.         thus does not delimit the range of a local symbol block.  
  913.  
  914.            Note that the range of a local symbol block may extend across
  915.         program areas.  
  916.  
  917.            Local symbols provide a convenient means of generating labels
  918.         for branch instructions and other such references  within  local
  919.         symbol  blocks.   Using local symbols reduces the possibility of
  920.         symbols with multiple definitions appearing within a  user  pro-
  921.         gram.   In  addition,  the  use  of local symbols differentiates
  922.         entry-point labels from local labels, since local labels  cannot
  923.         be referenced from outside their respective local symbol blocks.
  924.         Thus, local symbols of the same name can appear in  other  local
  925.         symbol blocks without conflict.  Local symbols require less sym-
  926.         bol table space than normal symbols.  Their use is recommended. 
  927.  
  928.            The  use of the same local symbol within a local symbol block
  929.         will generate one or both of the m or p errors.  
  930.  
  931.  
  932.         THE ASSEMBLER                                          PAGE 1-12
  933.         SYMBOLS AND EXPRESSIONS
  934.  
  935.  
  936.         Example of local symbols:  
  937.  
  938.                 a:      ldx     #atable ;get table address
  939.                         lda     #0d48   ;table length
  940.                 1$:     clr     ,x+     ;clear
  941.                         deca
  942.                         bne     1$
  943.                         
  944.                 b:      ldx     #btable ;get table address
  945.                         lda     #0d48   ;table length
  946.                 1$:     clr     ,x+     ;clear
  947.                         deca
  948.                         bne     1$
  949.  
  950.  
  951.         1.3.4  Current Location Counter 
  952.  
  953.  
  954.            The  period  (.) is the symbol for the current location coun-
  955.         ter.  When used in the operand  field  of  an  instruction,  the
  956.         period   represents  the  address  of  the  first  byte  of  the
  957.         instruction:  
  958.  
  959.                 AS:     ldx     #.      ;The period (.) refers to
  960.                                         ;the address of the ldx
  961.                                         ;instruction.
  962.  
  963.            When  used  in  the  operand field of an ASxxxx directive, it
  964.         represents the address of the current byte or word:  
  965.  
  966.                 QK = 0
  967.         
  968.                 .word   0xFFFE,.+4,QK   ;The operand .+4 in the .word
  969.                                         ;directive represents a value
  970.                                         ;stored in the second of the
  971.                                         ;three words during assembly.
  972.  
  973.            If  we  assume  the  current  value of the program counter is
  974.         0H0200, then during assembly, ASxxxx  reserves  three  words  of
  975.         storage  starting  at  location 0H0200.  The first value, a hex-
  976.         idecimal constant FFFE, will be stored at location 0H0200.   The
  977.         second  value  represented  by  .+4  will  be stored at location
  978.         0H0202, its value will be 0H0206 ( = 0H0202  +  4).   The  third
  979.         value  defined  by  the  symbol  QK  will  be placed at location
  980.         0H0204.  
  981.  
  982.            At the beginning of each assembly pass, ASxxxx resets the lo-
  983.         cation counter.  Normally, consecutive memory locations are  as-
  984.         signed  to  each  byte  of  object code generated.  However, the
  985.         value of the location counter can be changed  through  a  direct
  986.         assignment statement of the following form:  
  987.  
  988.  
  989.  
  990.         THE ASSEMBLER                                          PAGE 1-13
  991.         SYMBOLS AND EXPRESSIONS
  992.  
  993.  
  994.               . = . + expression 
  995.  
  996.  
  997.            The  new  location  counter can only be specified relative to
  998.         the current location counter.  Neglecting to specify the current
  999.         program  counter  along with the expression on the right side of
  1000.         the assignment operator will generate the (.) error.   (Absolute
  1001.         program areas may use the .org directive to specify the absolute
  1002.         location of the current program counter.) 
  1003.  
  1004.         The following coding illustrates the use of the current location
  1005.         counter:  
  1006.  
  1007.                 .area   CODE1   (ABS)   ;program area CODE1
  1008.                                         ;is ABSOLUTE
  1009.         
  1010.                 .org    0H100           ;set location to
  1011.                                         ;0H100 absolute
  1012.         
  1013.         num1:   ldx     #.+0H10         ;The label num1 has
  1014.                                         ;the value 0H100.
  1015.                                         ;X is loaded with
  1016.                                         ;0H100 + 0H10
  1017.         
  1018.                 .org    0H130           ;location counter
  1019.                                         ;set to 0H130
  1020.         
  1021.         num2:   ldy     #.              ;The label num2 has
  1022.                                         ;the value 0H130.
  1023.                                         ;Y is loaded with
  1024.                                         ;value 0H130.
  1025.         
  1026.         
  1027.                 .area   CODE2   (REL)   ;program area CODE2
  1028.                                         ;is RELOCATABLE
  1029.         
  1030.                 . = . + 0H20            ;Set location counter
  1031.                                         ;to relocatable 0H20 of
  1032.                                         ;the program section.
  1033.         
  1034.         num3:   .word   0               ;The label num3 has
  1035.                                         ;the value
  1036.                                         ;of relocatable 0H20.
  1037.         
  1038.                 . = . + 0H40            ;will reserve 0H40
  1039.                                         ;bytes of storage as will
  1040.                 .blkb   0H40            ;or
  1041.                 .blkw   0H20
  1042.  
  1043.            The  .blkb  and .blkw directives are the preferred methods of
  1044.         allocating space.  
  1045.  
  1046.  
  1047.  
  1048.         THE ASSEMBLER                                          PAGE 1-14
  1049.         SYMBOLS AND EXPRESSIONS
  1050.  
  1051.  
  1052.         1.3.5  Numbers 
  1053.  
  1054.  
  1055.            ASxxxx  assumes that all numbers in the source program are to
  1056.         be interpreted in decimal radix unless otherwise specified.  The
  1057.         .radix  directive  may  be used to specify the default as octal,
  1058.         decimal, or hexidecimal.  Individual numbers can  be  designated
  1059.         as  binary, octal, decimal, or hexidecimal through the temporary
  1060.         radix prefixes shown in table 6.  
  1061.  
  1062.            Negative  numbers  must be preceeded by a minus sign;  ASxxxx
  1063.         translates such numbers into two's  complement  form.   Positive
  1064.         numbers may (but need not) be preceeded by a plus sign.  
  1065.  
  1066.            Numbers are always considered to be absolute values, therefor
  1067.         they are never relocatable.  
  1068.  
  1069.  
  1070.         1.3.6  Terms 
  1071.  
  1072.  
  1073.            A  term is a component of an expression and may be one of the
  1074.         following:  
  1075.  
  1076.  
  1077.              1.  A number.  
  1078.  
  1079.              2.  A symbol:  
  1080.                  1.  A  period (.) specified in an expression causes the
  1081.                      current location counter to be used.  
  1082.                  2.  A User-defined symbol.  
  1083.                  3.  An undefined symbol is assigned a value of zero and
  1084.                      inserted in the User-Defined symbol table as an un-
  1085.                      defined symbol.  
  1086.  
  1087.              3.  A single quote followed by a single ascii character, or
  1088.                  a double quote followed by two ascii characters.  
  1089.  
  1090.              4.  An  expression enclosed in parenthesis.  Any expression
  1091.                  so enclosed is evaluated and reduced to a  single  term
  1092.                  before  the remainder of the expression in which it ap-
  1093.                  pears is evaluated.  Parenthesis, for example,  may  be
  1094.                  used  to  alter the left-to-right evaluation of expres-
  1095.                  sions, (as in A*B+C versus A*(B+C)), or to apply a  un-
  1096.                  ary operator to an entire expression (as in -(A+B)).  
  1097.  
  1098.              5.  A unary operator followed by a symbol or number.  
  1099.  
  1100.  
  1101.  
  1102.  
  1103.  
  1104.         THE ASSEMBLER                                          PAGE 1-15
  1105.         SYMBOLS AND EXPRESSIONS
  1106.  
  1107.  
  1108.         1.3.7  Expressions 
  1109.  
  1110.  
  1111.            Expressions  are  combinations  of  terms  joined together by
  1112.         binary operators.  Expressions reduce to a  16-bit  value.   The
  1113.         evaluation  of  an  expression includes the determination of its
  1114.         attributes.  A resultant expression value may be  one  of  three
  1115.         types  (as  described  later in this section):  relocatable, ab-
  1116.         solute, and external.  
  1117.  
  1118.         Expressions are evaluate with an operand hierarchy as follows:  
  1119.  
  1120.                 *       /       %       multiplication,
  1121.                                         division, and
  1122.                                         modulus first.
  1123.         
  1124.                 +       -               addition and
  1125.                                         subtraction second.
  1126.         
  1127.                 <<      >>              left shift and
  1128.                                         right shift third.
  1129.         
  1130.                 ^                       exclusive or fourth.
  1131.         
  1132.                 &                       logical and fifth.
  1133.         
  1134.                 |                       logical or last
  1135.         
  1136.                 except that unary operators take precedence over binary
  1137.                 operators.
  1138.  
  1139.  
  1140.            A  missing  or  illegal  operator  terminates  the expression
  1141.         analysis, causing error codes (o) and/or  (q)  to  be  generated
  1142.         depending upon the context of the expression itself.  
  1143.  
  1144.            At assembly time the value of an external (global) expression
  1145.         is equal to the value of the absolute part of  that  expression.
  1146.         For  example,  the expression external+4, where 'external' is an
  1147.         external symbol, has the value of 4.  This expression,  however,
  1148.         when  evaluated  at link time takes on the resolved value of the
  1149.         symbol 'external', plus 4.  
  1150.  
  1151.            Expressions,  when  evaluated  by  ASxxxx,  are  one of three
  1152.         types:  relocatable, absolute, or external.  The following  dis-
  1153.         tinctions are important:  
  1154.  
  1155.              1.  An  expression is relocatable if its value is fixed re-
  1156.                  lative to the base address of the program area in which
  1157.                  it appears;  it will have an offset value added at link
  1158.                  time.  Terms that contain labels defined in relocatable
  1159.                  program   areas   will   have   a   relocatable  value;
  1160.  
  1161.  
  1162.         THE ASSEMBLER                                          PAGE 1-16
  1163.         SYMBOLS AND EXPRESSIONS
  1164.  
  1165.  
  1166.                  similarly, a period (.) in a relocatable program  area,
  1167.                  representing  the value of the current program location
  1168.                  counter, will also have a relocatable value.  
  1169.  
  1170.              2.  An  expression  is  absolute if its value is fixed.  An
  1171.                  expression whose terms are numbers and ascii characters
  1172.                  will  reduce  to  an absolute value.  A relocatable ex-
  1173.                  pression or term minus a relocatable term,  where  both
  1174.                  elements  being  evaluated  belong  to the same program
  1175.                  area, is an absolute expression.  This is because every
  1176.                  term  in  a  program area has the same relocation bias.
  1177.                  When one term is subtracted from the other the  reloca-
  1178.                  tion bias is zero.  
  1179.  
  1180.              3.  An  expression is external (or global) if it contains a
  1181.                  single global reference (plus or minus an absolute  ex-
  1182.                  pression  value) that is not defined within the current
  1183.                  program.  Thus, an external  expression  is  only  par-
  1184.                  tially  defined following assembly and must be resolved
  1185.                  at link time.  
  1186.  
  1187.  
  1188.  
  1189.         1.4  GENERAL ASSEMBLER DIRECTIVES 
  1190.  
  1191.  
  1192.            An  ASxxxx  directive  is placed in the operator field of the
  1193.         source line.  Only one directive is  allowed  per  source  line.
  1194.         Each  directive  may  have  a blank operand field or one or more
  1195.         operands.  Legal operands differ with each directive.  
  1196.  
  1197.  
  1198.         1.4.1  .module Directive 
  1199.  
  1200.         Format:  
  1201.  
  1202.                 .module string 
  1203.  
  1204.            The .module directive causes the string to be included in the
  1205.         assemblers output file as an identifier for this particular  ob-
  1206.         ject  module.   The  string  may  be  from  1 to 8 characters in
  1207.         length.  Only one identifier is allowed  per  assembled  module.
  1208.         The  main use of this directive is to allow the linker to report
  1209.         a modules' use of undefined symbols.  At link time all undefined
  1210.         symbols  are  reported  and  the  modules  referencing  them are
  1211.         listed.  
  1212.  
  1213.  
  1214.  
  1215.  
  1216.         THE ASSEMBLER                                          PAGE 1-17
  1217.         GENERAL ASSEMBLER DIRECTIVES
  1218.  
  1219.  
  1220.         1.4.2  .title Directive 
  1221.  
  1222.         Format:  
  1223.  
  1224.                 .title  string 
  1225.  
  1226.            The .title directive provides a character string to be placed
  1227.         on the second line of each page during listing.  
  1228.  
  1229.  
  1230.         1.4.3  .sbttl Directive 
  1231.  
  1232.         Format:  
  1233.  
  1234.                 .sbttl  string 
  1235.  
  1236.            The .sbttl directive provides a character string to be placed
  1237.         on the third line of each page during listing.  
  1238.  
  1239.  
  1240.         1.4.4  .page Directive 
  1241.  
  1242.         Format:  
  1243.  
  1244.                 .page 
  1245.  
  1246.            The .page directive causes a page ejection with a new heading
  1247.         to be printed.  The new page occurs after the next line  of  the
  1248.         source  program is processed, this allows an immediately follow-
  1249.         ing .sbttl directive to appear  on  the  new  page.   The  .page
  1250.         source line will not appear in the file listing.  
  1251.  
  1252.  
  1253.         1.4.5  .byte and .db Directives 
  1254.  
  1255.         Format:  
  1256.  
  1257.                 .byte   exp             ;Stores the binary value
  1258.                 .db     exp             ;of the expression in the
  1259.                                         ;next byte.
  1260.         
  1261.                 .byte   exp1,exp2,expn  ;Stores the binary values
  1262.                 .db     exp1,exp2,expn  ;of the list of expressions
  1263.                                         ;in successive bytes.
  1264.         
  1265.         where:  exp,    represent expressions that will be
  1266.                 exp1,   truncated to 8-bits of data.
  1267.                 .       Each expression will be calculated
  1268.                 .       as a 16-bit word expression,
  1269.                 .       the high-order byte will be truncated.
  1270.                 .       Multiple expressions must be
  1271.                 expn    separated by commas.
  1272.  
  1273.  
  1274.         THE ASSEMBLER                                          PAGE 1-18
  1275.         GENERAL ASSEMBLER DIRECTIVES
  1276.  
  1277.  
  1278.            The  .byte  or .db directives are used to generate successive
  1279.         bytes of binary data in the object module.  
  1280.  
  1281.  
  1282.         1.4.6  .word and .dw Directives 
  1283.  
  1284.         Format:  
  1285.  
  1286.                 .word   exp             ;Stores the binary value
  1287.                 .dw     exp             ;of the expression in
  1288.                                         ;the next word.
  1289.         
  1290.                 .word   exp1,exp2,expn  ;Stores the binary values
  1291.                 .dw     exp1,exp2,expn  ;of the list of expressions
  1292.                                         ;in successive words.
  1293.         
  1294.         where:  exp,    represent expressions that will occupy two
  1295.                 exp1,   bytes of data. Each expression will be
  1296.                 .       calculated as a 16-bit word expression.
  1297.                 .       Multiple expressions must be
  1298.                 expn    separated by commas.
  1299.  
  1300.            The  .word  or .dw directives are used to generate successive
  1301.         words of binary data in the object module.  
  1302.  
  1303.  
  1304.         1.4.7  .blkb, .blkw, and .ds Directives 
  1305.  
  1306.         Format:  
  1307.  
  1308.                 .blkb   N       ;reserve N bytes of space
  1309.                 .blkw   N       ;reserve N words of space
  1310.                 .ds     N       ;reserve N bytes of space
  1311.  
  1312.            The  .blkb  and .ds directives reserve byte blocks in the ob-
  1313.         ject module;  the .blkw directive reserves word blocks.  
  1314.  
  1315.  
  1316.         1.4.8  .ascii Directive 
  1317.  
  1318.         Format:  
  1319.  
  1320.                 .ascii  /string/ 
  1321.  
  1322.         where:  string  is a string of printable ascii characters.  
  1323.  
  1324.                 /  /    represent   the  delimiting  characters.   These
  1325.                         delimiters   may   be   any   paired    printing
  1326.                         characters,  as  long  as the characters are not
  1327.                         contained within  the  string  itself.   If  the
  1328.                         delimiting  characters  do not match, the .ascii
  1329.                         directive will give the (q) error.  
  1330.  
  1331.  
  1332.         THE ASSEMBLER                                          PAGE 1-19
  1333.         GENERAL ASSEMBLER DIRECTIVES
  1334.  
  1335.  
  1336.  
  1337.         The  .ascii  directive  places  one binary byte of data for each
  1338.         character in the string into the object module.  
  1339.  
  1340.  
  1341.         1.4.9  .asciz Directive 
  1342.  
  1343.         Format:  
  1344.  
  1345.                 .asciz  /string/ 
  1346.  
  1347.         where:  string  is a string of printable asciz characters.  
  1348.  
  1349.                 /  /    represent   the  delimiting  characters.   These
  1350.                         delimiters   may   be   any   paired    printing
  1351.                         characters,  as  long  as the characters are not
  1352.                         contained within  the  string  itself.   If  the
  1353.                         delimiting  characters  do not match, the .asciz
  1354.                         directive will give the (q) error.  
  1355.  
  1356.         The  .ascii  directive  places  one binary byte of data for each
  1357.         character in the string into the object module.   Following  all
  1358.         the  character  data  a  zero  byte is inserted to terminate the
  1359.         character string.  
  1360.  
  1361.  
  1362.         1.4.10  .radix Directive 
  1363.  
  1364.         Format:  
  1365.  
  1366.                 .radix  character 
  1367.  
  1368.         where:  character  represents  a single character specifying the
  1369.                         default radix to be used for succeeding numbers.
  1370.                         The character may be any one of the following:  
  1371.  
  1372.                         B,b     Binary
  1373.         
  1374.                         O,o     Octal
  1375.                         Q,q
  1376.                         @
  1377.         
  1378.                         D,d     Decimal
  1379.                         'blank'
  1380.         
  1381.                         H,h     Hexidecimal
  1382.                         X,x
  1383.  
  1384.  
  1385.  
  1386.  
  1387.         THE ASSEMBLER                                          PAGE 1-20
  1388.         GENERAL ASSEMBLER DIRECTIVES
  1389.  
  1390.  
  1391.         1.4.11  .even Directive 
  1392.  
  1393.         Format:  
  1394.  
  1395.                 .even 
  1396.  
  1397.            The .even directive ensures that the current location counter
  1398.         contains an even boundary value by adding 1 if the current loca-
  1399.         tion is odd.  
  1400.  
  1401.  
  1402.         1.4.12  .odd Directive 
  1403.  
  1404.         Format:  
  1405.  
  1406.                 .odd 
  1407.  
  1408.            The  .odd directive ensures that the current location counter
  1409.         contains an odd boundary value by adding one if the current  lo-
  1410.         cation is even.  
  1411.  
  1412.  
  1413.         1.4.13  .area Directive 
  1414.  
  1415.         Format:  
  1416.  
  1417.                 .area   name    [(options)] 
  1418.  
  1419.         where:  name    represents the symbolic name of the program sec-
  1420.                         tion.   This  name  may  be  the  same  as   any
  1421.                         user-defined  symbol  as  the area names are in-
  1422.                         dependent of all symbols and labels.  
  1423.  
  1424.                 options specify the type of program or data area:  
  1425.                         ABS     absolute (automatically invokes OVR) 
  1426.                         REL     relocatable 
  1427.                         OVR     overlay 
  1428.                         CON     concatenate 
  1429.                         PAG     paged area 
  1430.  
  1431.  
  1432.            The .area directive provides a means of defining and separat-
  1433.         ing multiple programming and data sections.   The  name  is  the
  1434.         area  label used by the assembler and the linker to collect code
  1435.         from various separately assembled modules into one section.  The
  1436.         name may be from 1 to 8 characters in length.  
  1437.  
  1438.            The options are specified within parenthesis and separated by
  1439.         commas as shown in the following example:  
  1440.  
  1441.                 .area  TEST  (REL,CON)  ;This section is relocatable
  1442.                                         ;and concatenated with other
  1443.  
  1444.  
  1445.         THE ASSEMBLER                                          PAGE 1-21
  1446.         GENERAL ASSEMBLER DIRECTIVES
  1447.  
  1448.  
  1449.                                         ;sections of this program area.
  1450.         
  1451.                 .area  DATA  (REL,OVR)  ;This section is relocatable
  1452.                                         ;and overlays other sections
  1453.                                         ;of this program area.
  1454.         
  1455.                 .area  SYS   (ABS,OVR)  ;(CON not allowed with ABS)
  1456.                                         ;This section is defined as
  1457.                                         ;absolute. Absolute sections
  1458.                                         ;are always overlayed with
  1459.                                         ;other sections of this program
  1460.                                         ;area.
  1461.         
  1462.                 .area  PAGE  (PAG)      ;This is a paged section. The
  1463.                                         ;section must be on a 256 byte
  1464.                                         ;boundary and its length is
  1465.                                         ;checked by the linker to be
  1466.                                         ;no larger than 256 bytes.
  1467.                                         ;This is useful for direct page
  1468.                                         ;areas.
  1469.  
  1470.            The  default  area type is REL|CON;  i.e.  a relocatable sec-
  1471.         tion which is concatenated with other sections of code with  the
  1472.         same area name.  The ABS option indicates an absolute area.  The
  1473.         OVR and CON options indicate if program  sections  of  the  same
  1474.         name  will overlay each other (start at the same location) or be
  1475.         concatenated with each other (appended to each other).  
  1476.  
  1477.            Multiple  invocations  of  the  .area directive with the same
  1478.         name must specify the same options or leave  the  options  field
  1479.         blank,  this  defaults  to  the previously specified options for
  1480.         this program area.  
  1481.  
  1482.            The  ASxxxx  assemblers  automatically  provide  two  program
  1483.         sections:  
  1484.  
  1485.                 '.  .ABS.'      This dumby section contains all absolute
  1486.                                 symbols and their values.  
  1487.  
  1488.                 '_CODE'         This  is  the default program/data area.
  1489.                                 This program area is of type (REL,CON). 
  1490.  
  1491.  
  1492.  
  1493.  
  1494.         THE ASSEMBLER                                          PAGE 1-22
  1495.         GENERAL ASSEMBLER DIRECTIVES
  1496.  
  1497.  
  1498.         1.4.14  .org Directive 
  1499.  
  1500.         Format:  
  1501.  
  1502.                 .org    exp 
  1503.  
  1504.         where:  exp     is  an absolute expression that becomes the cur-
  1505.                         rent location counter.  
  1506.  
  1507.         The  .org directive is valid only in an absolute program section
  1508.         and will give a (q) error if used in a relocatable program area.
  1509.         The  .org  directive specifies that the current location counter
  1510.         is to become the specified absolute value.  
  1511.  
  1512.  
  1513.         1.4.15  .globl Directive 
  1514.  
  1515.         Format:  
  1516.  
  1517.                 .globl  sym1,sym2,...,symn 
  1518.  
  1519.         where:  sym1,           represent legal symbolic names. When
  1520.                 sym2,...        When multiple symbols are specified,
  1521.                 symn            they are separated by commas.
  1522.  
  1523.            A  .globl directive may also have a label field and/or a com-
  1524.         ment field.  
  1525.  
  1526.            The  .globl directive is provided to define (and thus provide
  1527.         linkage to) symbols not  otherwise  defined  as  global  symbols
  1528.         within  a  module.   In  defining  global  symbols the directive
  1529.         .globl J is similar to:  
  1530.  
  1531.               J == expression or J::  
  1532.  
  1533.            Because  object  modules  are linked by global symbols, these
  1534.         symbols are vital to a program.  All internal symbols  appearing
  1535.         within  a  given program must be defined at the end of pass 1 or
  1536.         they will be considered undefined.  The assembly directive  (-g)
  1537.         can  be  be  invoked to make all undefined symbols global at the
  1538.         end of pass 1.  
  1539.  
  1540.  
  1541.  
  1542.  
  1543.         THE ASSEMBLER                                          PAGE 1-23
  1544.         GENERAL ASSEMBLER DIRECTIVES
  1545.  
  1546.  
  1547.         1.4.16  .if, .else, and .endif Directives 
  1548.  
  1549.         Format:  
  1550.  
  1551.                 .if     expr
  1552.                 .                       ;}
  1553.                 .                       ;} range of true condition
  1554.                 .                       ;}
  1555.                 .else
  1556.                 .                       ;}
  1557.                 .                       ;} range of false condition
  1558.                 .                       ;}
  1559.                 .endif
  1560.  
  1561.            The  conditional  assembly directives allow you to include or
  1562.         exclude blocks of source code during the assembly process, based
  1563.         on the evaluation of the condition test.  
  1564.  
  1565.            The  range of true condition will be processed if the expres-
  1566.         sion 'expr' is not zero (i.e.  true) and the range of false con-
  1567.         dition  will  be processed if the expression 'expr' is zero (i.e
  1568.         false).  The range of true condition is optional as is the .else
  1569.         directive  and  the range of false condition.  The following are
  1570.         all valid .if/.else/.endif constructions:  
  1571.  
  1572.                 .if     A-4             ;evaluate A-4
  1573.                 .byte   1,2             ;insert bytes if A-4 is
  1574.                 .endif                  ;not zero
  1575.         
  1576.                 .if     K+3             ;evaluate K+3
  1577.                 .else
  1578.                 .byte   3,4             ;insert bytes if K+3
  1579.                 .endif                  ;is zero
  1580.         
  1581.                 .if     J&3             ;evaluate J masked by 3
  1582.                 .byte   12              ;insert this byte if J&3
  1583.                 .else                   ;is not zero
  1584.                 .byte   13              ;insert this byte if J&3
  1585.                 .endif                  ;is zero
  1586.  
  1587.  
  1588.         The .if/.else/.endif directives may be nested upto 10 levels.  
  1589.  
  1590.            The  .page  directive  is  processed within a false condition
  1591.         range to allow extended textual information to  be  incorporated
  1592.         in  the  source  program  with  out  the need to use the comment
  1593.         delimiter (;):  
  1594.  
  1595.                 .if     0
  1596.         
  1597.                 .page
  1598.                 This text will be bypassed during assembly
  1599.  
  1600.  
  1601.         THE ASSEMBLER                                          PAGE 1-24
  1602.         GENERAL ASSEMBLER DIRECTIVES
  1603.  
  1604.  
  1605.                 but appear in the listing file.
  1606.                 .
  1607.                 .
  1608.                 .
  1609.         
  1610.                 .endif
  1611.  
  1612.  
  1613.         1.4.17  .include Directive 
  1614.  
  1615.         Format:  
  1616.  
  1617.                 .include        string 
  1618.  
  1619.         where:  string  represents  a  delimited string that is the file
  1620.                         specification of an ASxxxx source file.  
  1621.  
  1622.            The .include directive is used to insert a source file within
  1623.         the source file currently being assembled.  When this  directive
  1624.         is encountered, an implicit .page directive is issued.  When the
  1625.         end of the specified source file is reached, an  implicit  .page
  1626.         directive is issued and input continues from the previous source
  1627.         file.  The maximum nesting level of source files specified by  a
  1628.         .include  directive  is  five.  The line containing the .include
  1629.         directive will not appear in the listing file.  
  1630.  
  1631.            The  total  number  of separately specified .include files is
  1632.         unlimited as each .include file is opened and then closed during
  1633.         each pass made by the assembler.  
  1634.  
  1635.  
  1636.         1.4.18  .setdp Directive 
  1637.  
  1638.         Format:  
  1639.  
  1640.                 .setdp [base [,area]] 
  1641.  
  1642.         The  set  direct  page  directive has a common format in all the
  1643.         AS68xx assemblers.  The .setdp directive is used to  inform  the
  1644.         assembler  of  the current direct page region and the offset ad-
  1645.         dress within the selected area.  The normal  invocation  methods
  1646.         are:  
  1647.  
  1648.                 .area   DIRECT  (PAG)
  1649.                 .setdp
  1650.         
  1651.                 or
  1652.         
  1653.                 .setdp  0,DIRECT
  1654.  
  1655.         for  all  the  68xx microprocessors (the 6804 has only the paged
  1656.         ram area).  The commands specify that the direct page is in area
  1657.  
  1658.  
  1659.         THE ASSEMBLER                                          PAGE 1-25
  1660.         GENERAL ASSEMBLER DIRECTIVES
  1661.  
  1662.  
  1663.         DIRECT and its offset address is 0 (the only valid value for all
  1664.         but the 6809 microprocessor).  Be sure to place the DIRECT  area
  1665.         at address 0 during linking.  When the base address and area are
  1666.         not specified, then zero and the current area are the  defaults.
  1667.         If  a  .setdp directive is not issued the assembler defaults the
  1668.         direct page to the area "_CODE" at offset 0.  
  1669.  
  1670.            The  assembler  verifies  that  any  local variable used in a
  1671.         direct variable reference is located in this area.  Local  vari-
  1672.         able  and  constant value direct access addresses are checked to
  1673.         be within the address range from 0 to 255.  
  1674.  
  1675.            External direct references are assumed by the assembler to be
  1676.         in the correct area and have valid  offsets.   The  linker  will
  1677.         check all direct page relocations to verify that they are within
  1678.         the correct area.  
  1679.  
  1680.            The  6809  microprocessor  allows the selection of the direct
  1681.         page to be on any 256 byte boundary by loading  the  appropriate
  1682.         value  into the dp register.  Typically one would like to select
  1683.         the page boundary at link time, one method follows:  
  1684.  
  1685.                 .area   DIRECT  (PAG)   ; define the direct page
  1686.                 .setdp
  1687.                 .
  1688.                 .
  1689.                 .
  1690.                 .area   PROGRAM
  1691.                 .
  1692.                 ldd     #DIRECT         ; load the direct page register
  1693.                 tfr     a,dp            ; for access to the direct page
  1694.  
  1695.         At  link  time specify the base and global equates to locate the
  1696.         direct page:  
  1697.  
  1698.                 -b DIRECT = 0x1000
  1699.                 -g DIRECT = 0x1000
  1700.  
  1701.         Both  the  area address and offset value must be specified (area
  1702.         and variable names are independent).   The  linker  will  verify
  1703.         that  the  relocated  direct page accesses are within the direct
  1704.         page.  
  1705.  
  1706.  
  1707.         THE ASSEMBLER                                          PAGE 1-26
  1708.         GENERAL ASSEMBLER DIRECTIVES
  1709.  
  1710.  
  1711.         The  preceeding  sequence  could  be repeated for multiple paged
  1712.         areas, however an alternate method is to define a non-paged area
  1713.         and use the .setdp directive to specify the offset value:  
  1714.  
  1715.                 .area   DIRECT          ; define non-paged area
  1716.                 .
  1717.                 .
  1718.                 .
  1719.                 .area   PROGRAM
  1720.                 .
  1721.                 .setdp  0,DIRECT        ; direct page area
  1722.                 ldd     #DIRECT         ; load the direct page register
  1723.                 tfr     a,dp            ; for access to the direct page
  1724.                 .
  1725.                 .
  1726.                 .setdp  0x100,DIRECT    ; direct page area
  1727.                 ldd     #DIRECT+0x100   ; load the direct page register
  1728.                 tfr     a,dp            ; for access to the direct page
  1729.  
  1730.         The  linker  will  verify that subsequent direct page references
  1731.         are in the specified area and offset address range.  It  is  the
  1732.         programmers responsibility to load the dp register with the cor-
  1733.         rect page segment  corresponding  to  the  .setdp  base  address
  1734.         specified.  
  1735.  
  1736.            For  those  cases  where a single piece of code must access a
  1737.         defined data structure within a direct page and there  are  many
  1738.         pages,  define  a  dumby  direct page linked at address 0.  This
  1739.         dumby page is used only to define  the  variable  labels.   Then
  1740.         load  the dp register with the real base address but donot use a
  1741.         .setdp directive.  This method is equivalent to indexed address-
  1742.         ing,  where the dp register is the index register and the direct
  1743.         addressing is the offset.  
  1744.  
  1745.  
  1746.         1.5  INVOKING ASXXXX 
  1747.  
  1748.  
  1749.            The  ASxxxx  assemblers are command line oriented.  After the
  1750.         assembler is started, enter the option(s) and file(s) to  assem-
  1751.         ble following the 'argv:' prompt:  
  1752.  
  1753.         argv:  [-dqxgalosf] file1 [file2 file3 ...  file6] 
  1754.  
  1755.         The options are:  
  1756.  
  1757.                 d       decimal listing
  1758.                 q       octal   listing
  1759.                 x       hex     listing (default)
  1760.         
  1761.                         The listing radix affects the
  1762.                         .lst, .rel, and .sym files.
  1763.  
  1764.  
  1765.         THE ASSEMBLER                                          PAGE 1-27
  1766.         INVOKING ASXXXX
  1767.  
  1768.  
  1769.         
  1770.                 g       undefined symbols made global
  1771.                 a       all user symbols made global
  1772.         
  1773.                 l       create list   output file1.lst
  1774.                 o       create object output file1.rel
  1775.                 s       create symbol output file1.sym
  1776.         
  1777.                 f       flag relocatable references by  `   in the list-
  1778.         ing file
  1779.                 ff      flag relocatable references by mode in the list-
  1780.         ing file
  1781.  
  1782.            The file name for the .lst, .rel, and .sym files is the first
  1783.         file name specified in the command line.  All output  files  are
  1784.         ascii  text  files which may be edited, copied, etc.  The output
  1785.         files are the concatenation of all the input files, if files are
  1786.         to  be  assembled  independently  invoke  the assembler for each
  1787.         file.  
  1788.  
  1789.            The  .rel  file contains a radix directive so that the linker
  1790.         will use the proper conversion for this file.  Linked files  may
  1791.         have different radices.  
  1792.  
  1793.            If  the list (l) option is specified without the symbol table
  1794.         (s) option, the symbol table is placed at the end of the listing
  1795.         file.  
  1796.  
  1797.  
  1798.         1.6  ERRORS 
  1799.  
  1800.  
  1801.            The  ASxxxx assemblers provide limited diagnostic error codes
  1802.         during the assembly process, these errors will be noted  in  the
  1803.         listing file and printed on the stderr device.  The errors are: 
  1804.  
  1805.               (.)   This  error  is caused by an absolute direct assign-
  1806.                     ment of the current location counter 
  1807.                           . = expression (incorrect) 
  1808.                     rather than the correct 
  1809.                           . = . + expression 
  1810.  
  1811.               (a)   Indicates  a machine specific addressing or address-
  1812.                     ing mode error.  
  1813.  
  1814.               (b)   Indicates a direct page boundary error.  
  1815.  
  1816.               (d)   Indicates a direct page addressing error.  
  1817.  
  1818.               (i)   Caused  by  an  .include file error or an .if/.endif
  1819.                     mismatch.  
  1820.  
  1821.  
  1822.  
  1823.         THE ASSEMBLER                                          PAGE 1-28
  1824.         ERRORS
  1825.  
  1826.  
  1827.               (m)   Multiple  definitions  of  the  same label, multiple
  1828.                     .module directives, or multiple  conflicting  attri-
  1829.                     butes in an .area directive.  
  1830.  
  1831.               (o)   Directive  or  mnemonic error or the use of the .org
  1832.                     directive in a relocatable area.  
  1833.  
  1834.               (p)   Phase error:  label location changing between passes
  1835.                     2 and 3.  Normally caused by having  more  than  one
  1836.                     level of forward referencing.  
  1837.  
  1838.               (q)   Questionable syntax:  missing or improper operators,
  1839.                     terminators, or delimiters.  
  1840.  
  1841.               (r)   Relocation  error:   logic  operation attempted on a
  1842.                     relocatable term, addition of two relocatable terms,
  1843.                     subtraction  of two relocatable terms not within the
  1844.                     same programming area or external symbols.  
  1845.  
  1846.               (u)   Undefined symbol encountered during assembly.  
  1847.  
  1848.  
  1849.         1.7  LISTING FILE 
  1850.  
  1851.  
  1852.            The  (-l) option produces an ascii output listing file.  Each
  1853.         page of output contains a four line header:  
  1854.  
  1855.  
  1856.              1.  The ASxxxx program name and page number 
  1857.  
  1858.              2.  Title from a .title directive (if any) 
  1859.  
  1860.              3.  Subtitle from a .sbttl directive (if any) 
  1861.  
  1862.              4.  Blank line 
  1863.  
  1864.  
  1865.  
  1866.         Each succeeding line contains five fields:  
  1867.  
  1868.  
  1869.              1.  Error field (first three characters of line) 
  1870.  
  1871.              2.  Current location counter 
  1872.  
  1873.              3.  Generated code in byte format 
  1874.  
  1875.              4.  Source text line number 
  1876.  
  1877.              5.  Source text 
  1878.  
  1879.  
  1880.  
  1881.         THE ASSEMBLER                                          PAGE 1-29
  1882.         LISTING FILE
  1883.  
  1884.  
  1885.            The error field may contain upto 2 error flags indicating any
  1886.         errors encountered while assembling this line of source code.  
  1887.  
  1888.            The  current  location counter field displays the 16-bit pro-
  1889.         gram position.  This field will be in the selected radix.  
  1890.  
  1891.            The generated code follows the program location.  The listing
  1892.         radix determines the number of bytes that will be  displayed  in
  1893.         this field.  Hexidecimal listing allows six bytes of data within
  1894.         the field, decimal and octal allow four bytes within the  field.
  1895.         If more than one field of data is generated from the assembly of
  1896.         a single line of source code, then the data field is repeated on
  1897.         successive lines.  
  1898.  
  1899.            The source text line number is printed in decimal and is fol-
  1900.         lowed by the source text.  
  1901.  
  1902.            Two  special  cases  will  disable  the  listing of a line of
  1903.         source text:  
  1904.  
  1905.              1.  Source line with a .page directive is never listed.  
  1906.  
  1907.              2.  Source  line  with  a  .include  file  directive is not
  1908.                  listed unless the .include file cannot be opened.  
  1909.  
  1910.  
  1911.            Two  data  field  options  are  available to flag those bytes
  1912.         which will be relocated by the linker.   If  the  -f  option  is
  1913.         specified  then  each  byte to be relocated will be preceeded by
  1914.         the '`' character.  If the -ff option  is  specified  then  each
  1915.         byte  to  be relocated will be preceeded by one of the following
  1916.         characters:  
  1917.  
  1918.              1.  *   paged relocation 
  1919.  
  1920.              2.  u   unsigned byte relocation 
  1921.  
  1922.              3.  p   PCR byte or low  byte of word relocation 
  1923.  
  1924.              4.  q   PCR high byte of word relocation 
  1925.  
  1926.              5.  r   low  byte relocation 
  1927.  
  1928.              6.  s   high byte relocation 
  1929.  
  1930.  
  1931.  
  1932.  
  1933.  
  1934.         THE ASSEMBLER                                          PAGE 1-30
  1935.         SYMBOL TABLE FILE
  1936.  
  1937.  
  1938.         1.8  SYMBOL TABLE FILE 
  1939.  
  1940.  
  1941.            The symbol table has two parts:  
  1942.  
  1943.              1.  The alphabetically sorted list of symbols and/or labels
  1944.                  defined or referenced in the source program.  
  1945.  
  1946.              2.  A  list of the program areas defined during assembly of
  1947.                  the source program.  
  1948.  
  1949.  
  1950.            The sorted list of symbols and/or labels contains the follow-
  1951.         ing information:  
  1952.  
  1953.              1.  Program  area  number (none if absolute value or exter-
  1954.                  nal) 
  1955.  
  1956.              2.  The symbol or label 
  1957.  
  1958.              3.  Directly assigned symbol is denoted with an (=) sign 
  1959.  
  1960.              4.  The  value of a symbol, location of a label relative to
  1961.                  the program area base address (=0), or a ****  indicat-
  1962.                  ing the symbol or label is undefined.  
  1963.  
  1964.              5.  The  characters:   G - global, R - relocatable, and X -
  1965.                  external.  
  1966.  
  1967.  
  1968.            The list of program areas provides the correspondence between
  1969.         the program area numbers and the defined program areas, the size
  1970.         of the program areas, and the area flags (attributes).  
  1971.  
  1972.  
  1973.         1.9  OBJECT FILE 
  1974.  
  1975.  
  1976.            The  object  file is an ascii file containing the information
  1977.         needed by the linker to bind multiple object modules into a com-
  1978.         plete  loadable  memory  image.   The object module contains the
  1979.         following designators:  
  1980.  
  1981.                 [XDQ][HL]
  1982.                         X       Hexidecimal radix
  1983.                         D       Decimal radix
  1984.                         Q       Octal radix
  1985.         
  1986.                         H       Most significant byte first
  1987.                         L       Least significant byte first
  1988.         
  1989.                 H       Header 
  1990.  
  1991.  
  1992.         THE ASSEMBLER                                          PAGE 1-31
  1993.         OBJECT FILE
  1994.  
  1995.  
  1996.                 M       Module
  1997.                 A       Area
  1998.                 S       Symbol
  1999.                 T       Object code
  2000.                 R       Relocation information
  2001.                 P       Paging information
  2002.  
  2003.            Refer to the linker for a detailed description of each of the
  2004.         designators and the format of the information contained  in  the
  2005.         object file.  
  2006.  
  2007.  
  2008.  
  2009.  
  2010.  
  2011.  
  2012.  
  2013.  
  2014.  
  2015.  
  2016.  
  2017.  
  2018.  
  2019.  
  2020.                                     CHAPTER 2
  2021.  
  2022.                                    THE LINKER
  2023.  
  2024.  
  2025.  
  2026.  
  2027.  
  2028.         2.1  ASLINK RELOCATING LINKER 
  2029.  
  2030.  
  2031.            ASLINK is the companion linker for the ASxxxx assemblers.  
  2032.  
  2033.            The  program ASLINK is a general relocating linker performing
  2034.         the following functions:  
  2035.  
  2036.              1.  Bind multiple object modules into a single memory image 
  2037.  
  2038.              2.  Resolve inter-module symbol references 
  2039.  
  2040.              3.  Combine  code  belonging to the same area from multiple
  2041.                  object files into a single contiguous memory region 
  2042.  
  2043.              4.  Perform   byte   and   word  program  counter  relative
  2044.                  (pc or pcr) addressing calculations 
  2045.  
  2046.              5.  Define absolute symbol values at link time 
  2047.  
  2048.              6.  Define absolute area base address values at link time 
  2049.  
  2050.              7.  Produce Intel Hex or Motorola S19 output file 
  2051.  
  2052.              8.  Produce a map of the linked memory image 
  2053.  
  2054.  
  2055.  
  2056.  
  2057.  
  2058.         THE LINKER                                              PAGE 2-2
  2059.         INVOKING ASLINK
  2060.  
  2061.  
  2062.         2.2  INVOKING ASLINK 
  2063.  
  2064.  
  2065.            The  linker  may run in the command line mode or command file
  2066.         modes.  The allowed startup linker commands are:  
  2067.  
  2068.         -c/-f           command line / command file modes 
  2069.  
  2070.         -p/-n           enable/disable echo file.lnk input to stdout 
  2071.  
  2072.            If  command  line  mode is selected, all linker commands come
  2073.         from stdin, if the command file mode is  selected  the  commands
  2074.         are input from the specified file (extension must be .lnk).  
  2075.  
  2076.            The linker is started via 
  2077.  
  2078.                 ASLINK  -(cfpn) 
  2079.  
  2080.         After invoking the linker the valid options are:  
  2081.  
  2082.              1.  -i/-s   Intel Hex (file.ihx) or Motorola S19 (file.s19)
  2083.                  image output file.  
  2084.  
  2085.              2.  -m      Generate a map file (file.map).  This file con-
  2086.                  tains a list of the symbols (by area) with absolute ad-
  2087.                  dresses,  sizes  of  linked  areas,  and  other linking
  2088.                  information.  
  2089.  
  2090.              3.  -xdq    Specifies  the  number  radix  for the map file
  2091.                  (Hexidecimal, Decimal, or Octal).  
  2092.  
  2093.              4.  fileN   Files  to  be linked.  Files may be on the same
  2094.                  line as the above options or on a separate line(s)  one
  2095.                  file  per line or multiple files separated by spaces or
  2096.                  tabs.  
  2097.  
  2098.              5.  -b  area = expression (one definition per line) 
  2099.                  This  specifies  an area base address where the expres-
  2100.                  sion may contain constants and/or defined symbols  from
  2101.                  the linked files.  
  2102.  
  2103.              6.  -g  symbol = expression (one definition per line) 
  2104.                  This  specifies  the value for the symbol where the ex-
  2105.                  pression may contain constants and/or  defined  symbols
  2106.                  from the linked files.  
  2107.  
  2108.              7.  -e      or null line, terminates input to the linker.  
  2109.  
  2110.  
  2111.  
  2112.  
  2113.  
  2114.         THE LINKER                                              PAGE 2-3
  2115.         ASLINK PROCESSING
  2116.  
  2117.  
  2118.         2.3  ASLINK PROCESSING 
  2119.  
  2120.  
  2121.            The  linker  processes  the  files  in  the  order  they  are
  2122.         presented.  The first pass through the input files  is  used  to
  2123.         define  all  program  areas, the section area sizes, and symbols
  2124.         defined or referenced.  After the first pass the -b  (area  base
  2125.         address)  definitions,  if  any,  are  processed  and  the areas
  2126.         linked.  
  2127.  
  2128.            The  area  linking proceeds by first examining the area types
  2129.         ABS, CON, REL, OVR and PAG.  Absolute areas (ABS) from  separate
  2130.         object modules are always overlayed and have been assembled at a
  2131.         specific address, these are not normally relocated (if a -b com-
  2132.         mand  is  used  on an absolute area the area will be relocated).
  2133.         Relative areas (normally defined as REL|CON) have a base address
  2134.         of  0x0000  as read from the object files, the -b command speci-
  2135.         fies the beginning address of the area.  All subsequent relative
  2136.         areas  will  be  concatenated  with  proceeding  relative areas.
  2137.         Where specific ordering is desired, the first linker input  file
  2138.         should  have  the area definitions in the desired order.  At the
  2139.         completion of the area linking all area  addresses  and  lengths
  2140.         have  been determined.  The areas of type PAG are verified to be
  2141.         on a 256 byte boundary and that the length does not  exceed  256
  2142.         bytes.  Any errors are noted on stderr and in the map file.  
  2143.  
  2144.            Next  the  global symbol definitions (-g option), if any, are
  2145.         processed.  The symbol definitions have been delayed until  this
  2146.         point because the absolute addresses of all internal symbols are
  2147.         known and can be used in the expression calculations.  
  2148.  
  2149.            Before  continuing  with the linking process the symbol table
  2150.         is scanned to determine if any symbols have been referenced  but
  2151.         not defined.  Undefined symbols are listed on the stderr device.
  2152.         if a .module directive was included in the  assembled  file  the
  2153.         module  making  the reference to this undefined variable will be
  2154.         printed.  
  2155.  
  2156.            Constants  defined  as global in more than one module will be
  2157.         flagged as multiple definitions if their values are not  identi-
  2158.         cal.  
  2159.  
  2160.            After  the  preceeding  processes are complete the linker may
  2161.         output a map file (-m option).  This file provides the following
  2162.         information:  
  2163.  
  2164.              1.  Global symbol values and label absolute addresses 
  2165.  
  2166.              2.  Defined areas and there lengths 
  2167.  
  2168.              3.  Remaining undefined symbols 
  2169.  
  2170.  
  2171.  
  2172.         THE LINKER                                              PAGE 2-4
  2173.         ASLINK PROCESSING
  2174.  
  2175.  
  2176.              4.  List of modules linked 
  2177.  
  2178.              5.  List of -b and -g definitions 
  2179.  
  2180.  
  2181.  
  2182.  
  2183.            The final step of the linking process is performed during the
  2184.         second pass of the input files.  As the xxx.rel files  are  read
  2185.         the code is relocated by substituting the physical addresses for
  2186.         the referenced symbols and areas and may be output in  Intel  or
  2187.         Motorola  formats.   The  number of files linked and symbols de-
  2188.         fined/referenced is limited by the processor space available  to
  2189.         build the area/symbol lists.  
  2190.  
  2191.  
  2192.         2.4  LINKER INPUT FORMAT 
  2193.  
  2194.  
  2195.            The  linkers'  input  object file is an ascii file containing
  2196.         the information needed by the linker  to  bind  multiple  object
  2197.         modules into a complete loadable memory image.  
  2198.  
  2199.         The object module contains the following designators:  
  2200.  
  2201.                 [XDQ][HL]
  2202.                         X       Hexidecimal radix
  2203.                         D       Decimal radix
  2204.                         Q       Octal radix
  2205.         
  2206.                         H       Most significant byte first
  2207.                         L       Least significant byte first
  2208.         
  2209.                 H       Header 
  2210.                 M       Module
  2211.                 A       Area
  2212.                 S       Symbol
  2213.                 T       Object code
  2214.                 R       Relocation information
  2215.                 P       Paging information
  2216.  
  2217.  
  2218.  
  2219.  
  2220.         THE LINKER                                              PAGE 2-5
  2221.         LINKER INPUT FORMAT
  2222.  
  2223.  
  2224.         2.4.1  Object Module Format 
  2225.  
  2226.  
  2227.            The  first  line  of  an object module contains the [XDQ][HL]
  2228.         format specifier (i.e.  XH indicates  a  hexidecimal  file  with
  2229.         most significant byte first) for the following designators.  
  2230.  
  2231.  
  2232.         2.4.2  Header Line 
  2233.  
  2234.                 H aa areas gg global symbols 
  2235.  
  2236.            The  header  line  specifies  the number of areas(aa) and the
  2237.         number of global symbols(gg) defined or referenced in  this  ob-
  2238.         ject module segment.  
  2239.  
  2240.  
  2241.         2.4.3  Module Line 
  2242.  
  2243.                 M name 
  2244.  
  2245.            The  module  line  specifies  the module name from which this
  2246.         header segment was assembled.  The module line will  not  appear
  2247.         if the .module directive was not used in the source program.  
  2248.  
  2249.  
  2250.         2.4.4  Symbol Line 
  2251.  
  2252.                 S string Defnnnn 
  2253.  
  2254.                         or 
  2255.  
  2256.                 S string Refnnnn 
  2257.  
  2258.            The  symbol line defines (Def) or references (Ref) the symbol
  2259.         'string' with the value nnnn.  The defined value is relative  to
  2260.         the  current area base address.  References to constants and ex-
  2261.         ternal global symbols will always appear before the  first  area
  2262.         definition.  References to external symbols will have a value of
  2263.         zero.  
  2264.  
  2265.  
  2266.  
  2267.  
  2268.         THE LINKER                                              PAGE 2-6
  2269.         LINKER INPUT FORMAT
  2270.  
  2271.  
  2272.         2.4.5  Area Line 
  2273.  
  2274.                 A label size ss flags ff 
  2275.  
  2276.            The  area  line  defines the area label, the size (ss) of the
  2277.         area in bytes, and the area flags (ff).  The area flags  specify
  2278.         the ABS, REL, CON, OVR, and PAG parameters:  
  2279.  
  2280.                 OVR/CON (0x04/0x00 i.e.  bit position 2) 
  2281.  
  2282.                 ABS/REL (0x08/0x00 i.e.  bit position 3) 
  2283.  
  2284.                 PAG (0x10 i.e.  bit position 4) 
  2285.  
  2286.  
  2287.         2.4.6  T Line 
  2288.  
  2289.                 T xx xx nn nn nn nn nn ...  
  2290.  
  2291.            The  T  line contains the assembled code output by the assem-
  2292.         bler with xx xx being the offset address from the  current  area
  2293.         base address and nn being the assembled instructions and data in
  2294.         byte format.  
  2295.  
  2296.  
  2297.         2.4.7  R Line 
  2298.  
  2299.                 R 0 0 nn nn n1 n2 xx xx ...  
  2300.  
  2301.            The R line provides the relocation information to the linker.
  2302.         The nn nn value is the current area index, i.e.  which area  the
  2303.         current  values  were  assembled.  Relocation information is en-
  2304.         coded in groups of 4 bytes:  
  2305.  
  2306.              1.  n1 is the relocation mode and object format 
  2307.                  1.  bit 0 word(0x00)/byte(0x01) 
  2308.                  2.  bit 1 relocatable area(0x00)/symbol(0x02) 
  2309.                  3.  bit 2 normal(0x00)/PC relative(0x04) relocation 
  2310.                  4.  bit  3  1-byte(0x00)/2-byte(0x08) object format for
  2311.                      byte data 
  2312.                  5.  bit 4 signed(0x00)/unsigned(0x10) byte data 
  2313.                  6.  bit 5 normal(0x00)/page '0'(0x20) reference 
  2314.                  7.  bit 6 normal(0x00)/page 'nnn'(0x40) reference 
  2315.  
  2316.              2.  n2  is  a byte index into the corresponding (i.e.  pre-
  2317.                  ceeding) T line data (i.e.  a pointer to the data to be
  2318.                  updated  by  the  relocation).   The T line data may be
  2319.                  1-byte or  2-byte  byte  data  format  or  2-byte  word
  2320.                  format.  
  2321.  
  2322.  
  2323.  
  2324.         THE LINKER                                              PAGE 2-7
  2325.         LINKER INPUT FORMAT
  2326.  
  2327.  
  2328.              3.  xx xx  is the area/symbol index for the area/symbol be-
  2329.                  ing referenced.  the corresponding area/symbol is found
  2330.                  in the header area/symbol lists.  
  2331.  
  2332.  
  2333.         The groups of 4 bytes are repeated for each item requiring relo-
  2334.         cation in the preceeding T line.  
  2335.  
  2336.  
  2337.         2.4.8  P Line 
  2338.  
  2339.                 P 0 0 nn nn n1 n2 xx xx 
  2340.  
  2341.            The  P  line provides the paging information to the linker as
  2342.         specified by a .setdp directive.  The format of  the  relocation
  2343.         information is identical to that of the R line.  The correspond-
  2344.         ing T line has the following information:  
  2345.                 T xx xx aa aa bb bb 
  2346.  
  2347.            Where  aa aa is the area reference number which specifies the
  2348.         selected page area and bb bb is the base address  of  the  page.
  2349.         bb bb will require relocation processing if the 'n1 n2 xx xx' is
  2350.         specified in the P line.  The linker will verify that  the  base
  2351.         address is on a 256 byte boundary and that the page length of an
  2352.         area defined with the PAG type is not larger than 256 bytes.  
  2353.  
  2354.            The  linker  defaults any direct page references to the first
  2355.         area defined in the input REL file.  All ASxxxx assemblers  will
  2356.         specify the _CODE area first, making this the default page area. 
  2357.  
  2358.  
  2359.         2.5  LINKER ERROR MESSAGES 
  2360.  
  2361.  
  2362.            The linker provides detailed error messages allowing the pro-
  2363.         grammer to quickly find the errant code.   As  the  linker  com-
  2364.         pletes  pass 1  over  the  input  file(s)  it  reports  any page
  2365.         boundary or page length errors as follows:  
  2366.  
  2367.         ?ASlink-W-Paged Area PAGE0 Boundary Error
  2368.         
  2369.         and/or
  2370.         
  2371.         ?ASlink-W-Paged Area PAGE0 Length Error
  2372.  
  2373.         where PAGE0 is the paged area.  
  2374.  
  2375.            During  Pass  two the linker reads the T, R, and P lines per-
  2376.         forming the necessary relocations and  outputting  the  absolute
  2377.         code.  Various errors may be reported during this process 
  2378.  
  2379.  
  2380.         THE LINKER                                              PAGE 2-8
  2381.         LINKER ERROR MESSAGES
  2382.  
  2383.  
  2384.         The P line processing can produce only one possible error:  
  2385.  
  2386.         ?ASlink-W-Page Definition Boundary Error
  2387.                  file        module      pgarea      pgoffset
  2388.           PgDef  t6809l      t6809l      PAGE0       0001
  2389.  
  2390.         The error message specifies the file and module where the .setdp
  2391.         direct was issued and indicates  the  page  area  and  the  page
  2392.         offset value determined after relocation.  
  2393.  
  2394.  
  2395.         The R line processing produces various errors:  
  2396.  
  2397.         ?ASlink-W-Byte PCR relocation error for symbol  bra2
  2398.                  file        module      area        offset
  2399.           Refby  t6809l      t6809l      TEST        00FE
  2400.           Defin  tconst      tconst      .  .ABS.    0080
  2401.  
  2402.         ?ASlink-W-Unsigned Byte error for symbol  two56
  2403.                  file        module      area        offset
  2404.           Refby  t6800l      t6800l      DIRECT      0015
  2405.           Defin  tconst      tconst      .  .ABS.    0100
  2406.  
  2407.         ?ASlink-W-Page0 relocation error for symbol  ltwo56
  2408.                  file        module      area        offset
  2409.           Refby  t6800l      t6800l      DIRECT      000D
  2410.           Defin  tconst      tconst      DIRECT      0100
  2411.  
  2412.         ?ASlink-W-Page Mode relocation error for symbol  two56
  2413.                  file        module      area        offset
  2414.           Refby  t6809l      t6809l      DIRECT      0005
  2415.           Defin  tconst      tconst      .  .ABS.    0100
  2416.  
  2417.         ?ASlink-W-Page Mode relocation error
  2418.                  file        module      area        offset
  2419.           Refby  t           Pagetest    PROGRAM     0006
  2420.           Defin  t           Pagetest    DIRECT      0100
  2421.  
  2422.         These  error messages specify the file, module, area, and offset
  2423.         within the area of the code  referencing  (Refby)  and  defining
  2424.         (Defin) the symbol.  If the symbol is defined in the same module
  2425.         as the reference the linker is unable to report the symbol name.
  2426.         The  assembler  listing file(s) should be examined at the offset
  2427.         from the specified area to located the offending code.  
  2428.  
  2429.            The errors are:  
  2430.  
  2431.              1.  The  byte PCR error is caused by exceeding the pc rela-
  2432.                  tive byte branch range.  
  2433.  
  2434.              2.  The Unsigned byte error indicates an indexing value was
  2435.                  negative or larger than 255.  
  2436.  
  2437.  
  2438.         THE LINKER                                              PAGE 2-9
  2439.         LINKER ERROR MESSAGES
  2440.  
  2441.  
  2442.              3.  The  Page0  error is generated if the direct page vari-
  2443.                  able is not in the page0 range of 0 to 255.  
  2444.  
  2445.              4.  The page mode error is generated if the direct variable
  2446.                  is not within the current direct page (6809).  
  2447.  
  2448.  
  2449.  
  2450.  
  2451.  
  2452.  
  2453.  
  2454.  
  2455.  
  2456.  
  2457.  
  2458.  
  2459.  
  2460.  
  2461.  
  2462.                                     CHAPTER 3
  2463.  
  2464.                            BUILDING ASXXXX AND ASLINK
  2465.  
  2466.  
  2467.  
  2468.  
  2469.            The assemblers and linker have been successfully compiled us-
  2470.         ing  the  DECUS C  (PDP-11)  compiler  (patch  level   9)   with
  2471.         RT-11/TSX+,  Eyring  Research  Institute,  Inc.   PDOS (680x0) C
  2472.         V5.4b compiler, and with  Borland's  Turbo C  V1.5  with  MS-DOS
  2473.         (80x86).  
  2474.  
  2475.            The  device  specific  header  file  (i.e.  m6800.h, m6801.h,
  2476.         etc.) contains the DECUS C 'BUILD' directives for  generating  a
  2477.         command  file to compile, assemble, and link the necessary files
  2478.         to prepare an executable image for a particular assembler.  
  2479.  
  2480.  
  2481.         3.1  BUILDING AN ASSEMBLER 
  2482.  
  2483.  
  2484.            The  building  of  a typical assembler (6809 for example) re-
  2485.         quires the following files:  
  2486.  
  2487.              1.  M6809.H 
  2488.              2.  M09EXT.C 
  2489.              3.  M09MCH.C 
  2490.              4.  M09ADR.C 
  2491.              5.  M09PST.C 
  2492.              6.  ASM.H 
  2493.              7.  ASMAIN.C 
  2494.              8.  ASLEX.C 
  2495.              9.  ASSYM.C 
  2496.             10.  ASSUBR.C 
  2497.             11.  ASEXPR.C 
  2498.             12.  ASDATA.C 
  2499.             13.  ASLIST.C 
  2500.             14.  ASOUT.C 
  2501.  
  2502.  
  2503.            The  first  five  files are the 6809 processor dependent sec-
  2504.         tions which contain the following:  
  2505.  
  2506.  
  2507.  
  2508.         BUILDING ASXXXX AND ASLINK                              PAGE 3-2
  2509.         BUILDING AN ASSEMBLER
  2510.  
  2511.  
  2512.              1.  m6809.h -  header  file containing the machine specific
  2513.                  definitions of constants,  variables,  structures,  and
  2514.                  types 
  2515.  
  2516.              2.  m09ext -  device  description, byte order, and file ex-
  2517.                  tension information 
  2518.  
  2519.              3.  m09pst -  a  table of the assembler general directives,
  2520.                  special device directives, and assembler mnemonics with
  2521.                  associated operation codes 
  2522.  
  2523.              4.  m09mch / m09adr -  machine specific code for processing
  2524.                  the device mnemonics,  addressing  modes,  and  special
  2525.                  directives 
  2526.  
  2527.  
  2528.            The  remaining nine files provide the device independent sec-
  2529.         tions which handle the  details  of  file  input/output,  symbol
  2530.         table  generation,  program/data areas, expression analysis, and
  2531.         assembler directive processing.  
  2532.  
  2533.            The  assembler defaults to the case sensitive mode.  This may
  2534.         be altered by changing the case sensitivity flag in asm.h to 
  2535.  
  2536.                 /*
  2537.                  * Case Sensitivity Flag
  2538.                  */
  2539.                 #define CASE_SENSITIVE  0
  2540.  
  2541.            The  assemblers  and  linker should be compiled with the same
  2542.         case sensitivity option.  
  2543.  
  2544.            The  DECUS C  build files are asxxxx.bld and the Turbo C pro-
  2545.         ject files are asxxxx.prj.  
  2546.  
  2547.  
  2548.         3.2  BUILDING ASLINK 
  2549.  
  2550.  
  2551.            The building of the linker requires the following files:  
  2552.  
  2553.              1.  ASLINK.H 
  2554.              2.  LKMAIN.C 
  2555.              3.  LKLEX.C 
  2556.              4.  LKAREA.C 
  2557.              5.  LKHEAD.C 
  2558.              6.  LKSYM.C 
  2559.              7.  LKEVAL.C 
  2560.              8.  LKDATA.C 
  2561.              9.  LKLIST.C 
  2562.             10.  LKRLOC.C 
  2563.  
  2564.  
  2565.         BUILDING ASXXXX AND ASLINK                              PAGE 3-3
  2566.         BUILDING ASLINK
  2567.  
  2568.  
  2569.             11.  LKS19.C 
  2570.             12.  LKIHX.C 
  2571.  
  2572.  
  2573.            The  linker defaults to the case sensitive mode.  This may be
  2574.         altered by changing the case sensitivity flag in aslink.h to 
  2575.  
  2576.                 /*
  2577.                  * Case Sensitivity Flag
  2578.                  */
  2579.                 #define CASE_SENSITIVE  0
  2580.  
  2581.            The  linker  and  assemblers should be compiled with the same
  2582.         case sensitivity option.  
  2583.  
  2584.            The  DECUS C build file is aslink.bld and the Turbo C project
  2585.         file is aslink.prj.  
  2586.  
  2587.  
  2588.  
  2589.  
  2590.  
  2591.  
  2592.  
  2593.  
  2594.  
  2595.  
  2596.  
  2597.  
  2598.  
  2599.  
  2600.                                    APPENDIX A
  2601.  
  2602.                                 AS6800 ASSEMBLER
  2603.  
  2604.  
  2605.  
  2606.  
  2607.  
  2608.         A.1  6800 REGISTER SET 
  2609.  
  2610.         The following is a list of the 6800 registers used by AS6800:  
  2611.  
  2612.                 a,b     -       8-bit accumulators
  2613.                 x       -       index register
  2614.  
  2615.  
  2616.         A.2  6800 INSTRUCTION SET 
  2617.  
  2618.  
  2619.            The following tables list all 6800/6802/6808 mnemonics recog-
  2620.         nized by the AS6800 assembler.  The designation [] refers  to  a
  2621.         required addressing mode argument.  The following list specifies
  2622.         the format for each addressing mode supported by AS6800:  
  2623.  
  2624.                 #data           immediate data
  2625.                                 byte or word data
  2626.         
  2627.                 *dir            direct page addressing
  2628.                                 (see .setdp directive)
  2629.                                 0 <= dir <= 255 
  2630.         
  2631.                 ,x              register indirect addressing
  2632.                                 zero offset
  2633.         
  2634.                 offset,x        register indirect addressing
  2635.                                 0 <= offset <= 255
  2636.         
  2637.                 ext             extended addressing
  2638.         
  2639.                 label           branch label
  2640.  
  2641.         The  terms  data, dir, offset, ext, and label may all be expres-
  2642.         sions.  
  2643.  
  2644.  
  2645.  
  2646.         AS6800 ASSEMBLER                                        PAGE A-2
  2647.         6800 INSTRUCTION SET
  2648.  
  2649.  
  2650.            Note  that  not all addressing modes are valid with every in-
  2651.         struction, refer to the 6800 technical data for valid modes.  
  2652.  
  2653.  
  2654.         A.2.1  Inherent Instructions 
  2655.  
  2656.                 aba                     cba
  2657.                 clc                     cli
  2658.                 clv                     daa
  2659.                 des                     dex
  2660.                 ins                     inx
  2661.                 nop                     rti
  2662.                 rts                     sba
  2663.                 sec                     sei
  2664.                 sev                     swi
  2665.                 tab                     tap
  2666.                 tba                     tpa
  2667.                 tsx                     txs
  2668.                 wai
  2669.         
  2670.                 psha                    pshb
  2671.                 psh a                   psh b
  2672.                 pula                    pulb
  2673.                 pul a                   pul b
  2674.  
  2675.  
  2676.         A.2.2  Branch Instructions 
  2677.  
  2678.                 bra     label           bhi     label
  2679.                 bls     label           bcc     label
  2680.                 bhs     label           bcs     label
  2681.                 blo     label           bne     label
  2682.                 beq     label           bvc     label
  2683.                 bvs     label           bpl     label
  2684.                 bmi     label           bge     label
  2685.                 blt     label           bgt     label
  2686.                 ble     label           bsr     label
  2687.  
  2688.  
  2689.         AS6800 ASSEMBLER                                        PAGE A-3
  2690.         6800 INSTRUCTION SET
  2691.  
  2692.  
  2693.         A.2.3  Single Operand Instructions 
  2694.  
  2695.                 asla                    aslb
  2696.                 asl a                   asl b
  2697.                 asl     []
  2698.         
  2699.                 asra                    asrb
  2700.                 asr a                   asr b
  2701.                 asr     []
  2702.         
  2703.                 clra                    clrb
  2704.                 clr a                   clr b
  2705.                 clr     []
  2706.         
  2707.                 coma                    comb
  2708.                 com a                   com b
  2709.                 com     []
  2710.         
  2711.                 deca                    decb
  2712.                 dec a                   dec b
  2713.                 dec     []
  2714.         
  2715.                 inca                    incb
  2716.                 inc a                   inc b
  2717.                 inc     []
  2718.         
  2719.                 lsla                    lslb
  2720.                 lsl a                   lsl b
  2721.                 lsl     []
  2722.         
  2723.                 lsra                    lsrb
  2724.                 lsr a                   lsr b
  2725.                 lsr     []
  2726.         
  2727.                 nega                    negb
  2728.                 neg a                   neg b
  2729.                 neg     []
  2730.         
  2731.                 rola                    rolb
  2732.                 rol a                   rol b
  2733.                 rol     []
  2734.         
  2735.                 rora                    rorb
  2736.                 ror a                   ror b
  2737.                 ror     []
  2738.         
  2739.                 tsta                    tstb
  2740.                 tst a                   tst b
  2741.                 tst     []
  2742.  
  2743.  
  2744.         AS6800 ASSEMBLER                                        PAGE A-4
  2745.         6800 INSTRUCTION SET
  2746.  
  2747.  
  2748.         A.2.4  Double Operand Instructions 
  2749.  
  2750.                 adca    []              adcb    []
  2751.                 adc a   []              adc b   []
  2752.         
  2753.                 adda    []              addb    []
  2754.                 add a   []              add b   []
  2755.         
  2756.                 anda    []              andb    []
  2757.                 and a   []              and b   []
  2758.         
  2759.                 bita    []              bitb    []
  2760.                 bit a   []              bit b   []
  2761.         
  2762.                 cmpa    []              cmpb    []
  2763.                 cmp a   []              cmp b   []
  2764.         
  2765.                 eora    []              eorb    []
  2766.                 eor a   []              eor b   []
  2767.         
  2768.                 ldaa    []              ldab    []
  2769.                 lda a   []              lda b   []
  2770.         
  2771.                 oraa    []              orab    []
  2772.                 ora a   []              ora b   []
  2773.         
  2774.                 sbca    []              sbcb    []
  2775.                 sbc a   []              sbc b   []
  2776.         
  2777.                 staa    []              stab    []
  2778.                 sta a   []              sta b   []
  2779.         
  2780.                 suba    []              subb    []
  2781.                 sub a   []              sub b   []
  2782.  
  2783.  
  2784.         A.2.5  Jump and Jump to Subroutine Instructions 
  2785.  
  2786.                 jmp     []              jsr     []
  2787.  
  2788.  
  2789.  
  2790.  
  2791.         AS6800 ASSEMBLER                                        PAGE A-5
  2792.         6800 INSTRUCTION SET
  2793.  
  2794.  
  2795.         A.2.6  Long Register Instructions 
  2796.  
  2797.                 cpx     []
  2798.                 lds     []              sts     []
  2799.                 ldx     []              stx     []
  2800.  
  2801.  
  2802.  
  2803.  
  2804.  
  2805.  
  2806.  
  2807.  
  2808.  
  2809.  
  2810.  
  2811.  
  2812.  
  2813.  
  2814.                                    APPENDIX B
  2815.  
  2816.                                 AS6801 ASSEMBLER
  2817.  
  2818.  
  2819.  
  2820.  
  2821.  
  2822.         B.1  .hd6303 DIRECTIVE 
  2823.  
  2824.         Format:  
  2825.  
  2826.                 .hd6303 
  2827.  
  2828.         The  .hd6303 directive enables processing of the HD6303 specific
  2829.         mnemonics not included in  the  6801  instruction  set.   HD6303
  2830.         mnemonics  encountered  without  the  .hd6303  directive will be
  2831.         flagged with an 'o' error.  
  2832.  
  2833.  
  2834.         B.2  6801 REGISTER SET 
  2835.  
  2836.         The following is a list of the 6801 registers used by AS6801:  
  2837.  
  2838.                 a,b     -       8-bit accumulators
  2839.                 d       -       16-bit accumulator <a:b>
  2840.                 x       -       index register
  2841.  
  2842.  
  2843.         B.3  6801 INSTRUCTION SET 
  2844.  
  2845.  
  2846.            The  following tables list all 6801/6303 mnemonics recognized
  2847.         by the AS6801 assembler.  The designation []  refers  to  a  re-
  2848.         quired  addressing  mode argument.  The following list specifies
  2849.         the format for each addressing mode supported by AS6801:  
  2850.  
  2851.                 #data           immediate data
  2852.                                 byte or word data
  2853.         
  2854.                 *dir            direct page addressing
  2855.                                 (see .setdp directive)
  2856.                                 0 <= dir <= 255 
  2857.         
  2858.  
  2859.  
  2860.         AS6801 ASSEMBLER                                        PAGE B-2
  2861.         6801 INSTRUCTION SET
  2862.  
  2863.  
  2864.                 ,x              register indirect addressing
  2865.                                 zero offset
  2866.         
  2867.                 offset,x        register indirect addressing
  2868.                                 0 <= offset <= 255
  2869.         
  2870.                 ext             extended addressing
  2871.         
  2872.                 label           branch label
  2873.  
  2874.         The  terms  data, dir, offset, ext, and label may all be expres-
  2875.         sions.  
  2876.  
  2877.            Note  that  not all addressing modes are valid with every in-
  2878.         struction, refer to  the  6801/6303  technical  data  for  valid
  2879.         modes.  
  2880.  
  2881.  
  2882.         B.3.1  Inherent Instructions 
  2883.  
  2884.                 aba             abx
  2885.                 cba             clc
  2886.                 cli             clv
  2887.                 daa             des
  2888.                 dex             ins
  2889.                 inx             mul
  2890.                 nop             rti
  2891.                 rts             sba
  2892.                 sec             sei
  2893.                 sev             swi
  2894.                 tab             tap
  2895.                 tba             tpa
  2896.                 tsx             txs
  2897.                 wai
  2898.  
  2899.  
  2900.         B.3.2  Branch Instructions 
  2901.  
  2902.                 bra     label           brn     label
  2903.                 bhi     label           bls     label
  2904.                 bcc     label           bhs     label
  2905.                 bcs     label           blo     label
  2906.                 bne     label           beq     label
  2907.                 bvc     label           bvs     label
  2908.                 bpl     label           bmi     label
  2909.                 bge     label           blt     label
  2910.                 bgt     label           ble     label
  2911.                 bsr     label
  2912.  
  2913.  
  2914.         AS6801 ASSEMBLER                                        PAGE B-3
  2915.         6801 INSTRUCTION SET
  2916.  
  2917.  
  2918.         B.3.3  Single Operand Instructions 
  2919.  
  2920.                 asla            aslb            asld
  2921.                 asl a           asl b           asl d
  2922.                 asl     []
  2923.         
  2924.                 asra            asrb
  2925.                 asr a           asr b
  2926.                 asr     []
  2927.         
  2928.                 clra            clrb
  2929.                 clr a           clr b
  2930.                 clr     []
  2931.         
  2932.                 coma            comb
  2933.                 com a           com b
  2934.                 com     []
  2935.         
  2936.                 deca            decb
  2937.                 dec a           dec b
  2938.                 dec     []
  2939.         
  2940.                 eora            eorb
  2941.                 eor a           eor b
  2942.                 eor     []
  2943.         
  2944.                 inca            incb
  2945.                 inc a           inc b
  2946.                 inc     []
  2947.         
  2948.                 lsla            lslb            lsld
  2949.                 lsl a           lsl b           lsl d
  2950.                 lsl     []
  2951.         
  2952.                 lsra            lsrb            lsrd
  2953.                 lsr a           lsr b           lsr d
  2954.                 lsr     []
  2955.         
  2956.                 nega            negb
  2957.                 neg a           neg b
  2958.                 neg     []
  2959.         
  2960.                 psha            pshb            pshx
  2961.                 psh a           psh b           psh x
  2962.         
  2963.                 pula            pulb            pulx
  2964.                 pul a           pul b           pul x
  2965.         
  2966.                 rola            rolb
  2967.                 rol a           rol b
  2968.                 rol     []
  2969.         
  2970.  
  2971.  
  2972.         AS6801 ASSEMBLER                                        PAGE B-4
  2973.         6801 INSTRUCTION SET
  2974.  
  2975.  
  2976.                 rora            rorb
  2977.                 ror a           ror b
  2978.                 ror     []
  2979.         
  2980.                 tsta            tstb
  2981.                 tst a           tst b
  2982.                 tst     []
  2983.  
  2984.  
  2985.         B.3.4  Double Operand Instructions 
  2986.  
  2987.                 adca    []      adcb    []
  2988.                 adc a   []      adc b   []
  2989.         
  2990.                 adda    []      addb    []      addd    []
  2991.                 add a   []      add b   []      add d   []
  2992.         
  2993.                 anda    []      andb    []
  2994.                 and a   []      and b   []
  2995.         
  2996.                 bita    []      bitb    []
  2997.                 bit a   []      bit b   []
  2998.         
  2999.                 cmpa    []      cmpb    []
  3000.                 cmp a   []      cmp b   []
  3001.         
  3002.                 ldaa    []      ldab    []
  3003.                 lda a   []      lda b   []
  3004.         
  3005.                 oraa    []      orab    []
  3006.                 ora a   []      ora b   []
  3007.         
  3008.                 sbca    []      sbcb    []
  3009.                 sbc a   []      sbc b   []
  3010.         
  3011.                 staa    []      stab    []
  3012.                 sta a   []      sta b   []
  3013.         
  3014.                 suba    []      subb    []      subd    []
  3015.                 sub a   []      sub b   []      sub d   []
  3016.  
  3017.  
  3018.  
  3019.  
  3020.         AS6801 ASSEMBLER                                        PAGE B-5
  3021.         6801 INSTRUCTION SET
  3022.  
  3023.  
  3024.         B.3.5  Jump and Jump to Subroutine Instructions 
  3025.  
  3026.                 jmp     []      jsr     []
  3027.  
  3028.  
  3029.         B.3.6  Long Register Instructions 
  3030.  
  3031.                 cpx     []      ldd     []
  3032.                 lds     []      ldx     []
  3033.                 std     []      sts     []
  3034.                 stx     []
  3035.  
  3036.  
  3037.         B.3.7  6303 Specific Instructions 
  3038.  
  3039.                 aim     #data, []       eim     #data, []
  3040.                 oim     #data, []       tim     #data, []
  3041.         
  3042.                 xgdx            slp
  3043.  
  3044.  
  3045.  
  3046.  
  3047.  
  3048.  
  3049.  
  3050.  
  3051.  
  3052.  
  3053.  
  3054.  
  3055.  
  3056.  
  3057.                                    APPENDIX C
  3058.  
  3059.                                 AS6804 ASSEMBLER
  3060.  
  3061.  
  3062.  
  3063.  
  3064.            Requires the .setdp directive to specify the ram area.  
  3065.  
  3066.  
  3067.         C.1  6804 REGISTER SET 
  3068.  
  3069.         The following is a list of the 6804 registers used by AS6804:  
  3070.  
  3071.                 x,y     -       index registers
  3072.  
  3073.  
  3074.         C.2  6804 INSTRUCTION SET 
  3075.  
  3076.  
  3077.            The  following  tables  list all 6804 mnemonics recognized by
  3078.         the AS6804 assembler.  The designation [] refers to  a  required
  3079.         addressing  mode  argument.   The  following  list specifies the
  3080.         format for each addressing mode supported by AS6804:  
  3081.  
  3082.                 #data           immediate data
  3083.                                 byte or word data
  3084.         
  3085.                 ,x              register indirect addressing
  3086.         
  3087.                 dir             direct addressing
  3088.                                 (see .setdp directive)
  3089.                                 0 <= dir <= 255
  3090.         
  3091.                 ext             extended addressing
  3092.         
  3093.                 label           branch label
  3094.  
  3095.         The  terms data, dir, and ext may be expressions.  The label for
  3096.         the short branchs beq, bne, bcc, and bcs must not be external.  
  3097.  
  3098.            Note  that  not all addressing modes are valid with every in-
  3099.         struction, refer to the 6804 technical data for valid modes.  
  3100.  
  3101.  
  3102.         AS6804 ASSEMBLER                                        PAGE C-2
  3103.         6804 INSTRUCTION SET
  3104.  
  3105.  
  3106.         C.2.1  Inherent Instructions 
  3107.  
  3108.                 coma            decx
  3109.                 decy            incx
  3110.                 incy            rola
  3111.                 rti             rts
  3112.                 stop            tax
  3113.                 tay             txa
  3114.                 tya             wait
  3115.  
  3116.  
  3117.         C.2.2  Branch Instructions 
  3118.  
  3119.                 bne     label           beq     label
  3120.                 bcc     label           bcs     label
  3121.  
  3122.  
  3123.         C.2.3  Single Operand Instructions 
  3124.  
  3125.                 add     []
  3126.                 and     []
  3127.                 cmp     []
  3128.                 dec     []
  3129.                 inc     []
  3130.                 lda     []
  3131.                 sta     []
  3132.                 sub     []
  3133.  
  3134.  
  3135.         C.2.4  Jump and Jump to Subroutine Instructions 
  3136.  
  3137.                 jsr     []
  3138.                 jmp     []
  3139.  
  3140.  
  3141.         C.2.5  Bit Test Instructions 
  3142.  
  3143.                 brclr   #data,[],label
  3144.                 brset   #data,[],label
  3145.         
  3146.                 bclr    #label,[]
  3147.                 bset    #label,[]
  3148.  
  3149.  
  3150.  
  3151.  
  3152.         AS6804 ASSEMBLER                                        PAGE C-3
  3153.         6804 INSTRUCTION SET
  3154.  
  3155.  
  3156.         C.2.6  Load Immediate data Instruction 
  3157.  
  3158.                 mvi     [],#data
  3159.  
  3160.  
  3161.         C.2.7  6804 Derived Instructions 
  3162.  
  3163.                 asla
  3164.                 bam     label
  3165.                 bap     label
  3166.                 bxmi    label
  3167.                 bxpl    label
  3168.                 bymi    label
  3169.                 bypl    label
  3170.                 clra
  3171.                 clrx
  3172.                 clry
  3173.                 deca
  3174.                 decx
  3175.                 decy
  3176.                 inca
  3177.                 incx
  3178.                 incy
  3179.                 ldxi    #data
  3180.                 ldyi    #data
  3181.                 nop
  3182.                 tax
  3183.                 tay
  3184.                 txa
  3185.                 tya
  3186.  
  3187.  
  3188.  
  3189.  
  3190.  
  3191.  
  3192.  
  3193.  
  3194.  
  3195.  
  3196.  
  3197.  
  3198.  
  3199.  
  3200.                                    APPENDIX D
  3201.  
  3202.                                 AS6805 ASSEMBLER
  3203.  
  3204.  
  3205.  
  3206.  
  3207.  
  3208.         D.1  6805 REGISTER SET 
  3209.  
  3210.         The following is a list of the 6805 registers used by AS6805:  
  3211.  
  3212.                 a       -       8-bit accumulator
  3213.                 x       -       index register
  3214.  
  3215.  
  3216.         D.2  6805 INSTRUCTION SET 
  3217.  
  3218.  
  3219.            The  following  tables  list all 6805 mnemonics recognized by
  3220.         the AS6805 assembler.  The designation [] refers to  a  required
  3221.         addressing  mode  argument.   The  following  list specifies the
  3222.         format for each addressing mode supported by AS6805:  
  3223.  
  3224.                 #data           immediate data
  3225.                                 byte or word data
  3226.         
  3227.                 *dir            direct page addressing
  3228.                                 (see .setdp directive)
  3229.                                 0 <= dir <= 255 
  3230.         
  3231.                 ,x              register indirect addressing
  3232.                                 zero offset
  3233.         
  3234.                 offset,x        register indirect addressing
  3235.                                   0 <= offset <= 255   --- byte mode
  3236.                                 256 <= offset <= 65535 --- word mode
  3237.                                 (an externally defined offset uses the
  3238.                                  word mode)
  3239.         
  3240.                 ext             extended addressing
  3241.         
  3242.                 label           branch label
  3243.  
  3244.  
  3245.  
  3246.         AS6805 ASSEMBLER                                        PAGE D-2
  3247.         6805 INSTRUCTION SET
  3248.  
  3249.  
  3250.         The terms data, dir, offset, and ext may all be expressions.  
  3251.  
  3252.            Note  that  not all addressing modes are valid with every in-
  3253.         struction, refer to the 6805 technical data for valid modes.  
  3254.  
  3255.  
  3256.         D.2.1  Control Instructions 
  3257.  
  3258.                 clc             cli
  3259.                 nop             rsp
  3260.                 rti             rts
  3261.                 sec             sei
  3262.                 stop            swi
  3263.                 tax             txa
  3264.                 wait
  3265.  
  3266.  
  3267.         D.2.2  Bit Manipulation Instructions 
  3268.  
  3269.                 brset   #data,*dir,label
  3270.                 brclr   #data,*dir,label
  3271.         
  3272.                 bset    #data,*dir
  3273.                 bclr    #data,*dir
  3274.  
  3275.  
  3276.         D.2.3  Branch Instructions 
  3277.  
  3278.                 bra     label           brn     label
  3279.                 bhi     label           bls     label
  3280.                 bcc     label           bcs     label
  3281.                 bne     label           beq     label
  3282.                 bhcc    label           bhcs    label
  3283.                 bpl     label           bmi     label
  3284.                 bmc     label           bms     label
  3285.                 bil     label           bih     label
  3286.                 bsr     label
  3287.  
  3288.  
  3289.         AS6805 ASSEMBLER                                        PAGE D-3
  3290.         6805 INSTRUCTION SET
  3291.  
  3292.  
  3293.         D.2.4  Read-Modify-Write Instructions 
  3294.  
  3295.                 nega            negx
  3296.                 neg     []
  3297.         
  3298.                 coma            comx
  3299.                 com     []
  3300.         
  3301.                 lsra            lsrx
  3302.                 lsr     []
  3303.         
  3304.                 rora            rorx
  3305.                 ror     []
  3306.         
  3307.                 asra            asrx
  3308.                 asr     []
  3309.         
  3310.                 asla            aslx
  3311.                 asl     []
  3312.         
  3313.                 lsla            lslx
  3314.                 lsl     []
  3315.         
  3316.                 rola            rolx
  3317.                 rol     []
  3318.         
  3319.                 deca            decx
  3320.                 dec     []
  3321.         
  3322.                 inca            incx
  3323.                 inc     []
  3324.         
  3325.                 tsta            tstx
  3326.                 tst     []
  3327.         
  3328.                 clra            clrx
  3329.                 clr     []
  3330.  
  3331.  
  3332.         D.2.5  Register\Memory Instructions 
  3333.  
  3334.                 sub     []              cmp     []
  3335.                 sbc     []              cpx     []
  3336.                 and     []              bit     []
  3337.                 lda     []              sta     []
  3338.                 eor     []              adc     []
  3339.                 ora     []              add     []
  3340.                 ldx     []              stx     []
  3341.  
  3342.  
  3343.         AS6805 ASSEMBLER                                        PAGE D-4
  3344.         6805 INSTRUCTION SET
  3345.  
  3346.  
  3347.         D.2.6  Jump and Jump to Subroutine Instructions 
  3348.  
  3349.                 jmp     []              jsr     []
  3350.  
  3351.  
  3352.  
  3353.  
  3354.  
  3355.  
  3356.  
  3357.  
  3358.  
  3359.  
  3360.  
  3361.  
  3362.  
  3363.  
  3364.                                    APPENDIX E
  3365.  
  3366.                                AS68HC08 ASSEMBLER
  3367.  
  3368.  
  3369.  
  3370.  
  3371.  
  3372.         E.1  68HC08 REGISTER SET 
  3373.  
  3374.         The  following  is  a  list  of  the  68HC08  registers  used by
  3375.         AS68HC08:  
  3376.  
  3377.                 a       -       8-bit accumulator
  3378.                 x       -       index register  <H:X>
  3379.                 s       -       stack pointer
  3380.  
  3381.  
  3382.         E.2  68HC08 INSTRUCTION SET 
  3383.  
  3384.  
  3385.            The  following tables list all 68HC08 mnemonics recognized by
  3386.         the AS68HC08 assembler.  The designation [] refers to a required
  3387.         addressing  mode  argument.   The  following  list specifies the
  3388.         format for each addressing mode supported by AS68HC08:  
  3389.  
  3390.                 #data           immediate data
  3391.                                 byte or word data
  3392.         
  3393.                 *dir            direct page addressing
  3394.                                 (see .setdp directive)
  3395.                                 0 <= dir <= 255 
  3396.         
  3397.                 ,x              register indexed addressing
  3398.                                 zero offset
  3399.         
  3400.                 offset,x        register indexed addressing
  3401.                                   0 <= offset <= 255   --- byte mode
  3402.                                 256 <= offset <= 65535 --- word mode
  3403.                                 (an externally defined offset uses the
  3404.                                  word mode)
  3405.         
  3406.                 ,x+             register indexed addressing
  3407.                                 zero offset with post increment
  3408.  
  3409.  
  3410.         AS68HC08 ASSEMBLER                                      PAGE E-2
  3411.         68HC08 INSTRUCTION SET
  3412.  
  3413.  
  3414.         
  3415.                 offset,x+       register indexed addressing
  3416.                                 unsigned byte offset with post increment
  3417.         
  3418.                 offset,s        stack pointer indexed addressing
  3419.                                   0 <= offset <= 255   --- byte mode
  3420.                                 256 <= offset <= 65535 --- word mode
  3421.                                 (an externally defined offset uses the
  3422.                                  word mode)
  3423.         
  3424.                 ext             extended addressing
  3425.         
  3426.                 label           branch label
  3427.  
  3428.         The terms data, dir, offset, and ext may all be expressions.  
  3429.  
  3430.            Note  that  not all addressing modes are valid with every in-
  3431.         struction, refer to the 68HC08 technical data for valid modes.  
  3432.  
  3433.  
  3434.         E.2.1  Control Instructions 
  3435.  
  3436.                 clc             cli             daa             div
  3437.                 mul             nop             nsa             psha
  3438.                 pshh            pshx            pula            pulh
  3439.                 pulx            rsp             rti             rts
  3440.                 sec             sei             stop            swi
  3441.                 tap             tax             tpa             tsx
  3442.                 txa             txs             wait
  3443.  
  3444.  
  3445.         E.2.2  Bit Manipulation Instructions 
  3446.  
  3447.                 brset   #data,*dir,label
  3448.                 brclr   #data,*dir,label
  3449.         
  3450.                 bset    #data,*dir
  3451.                 bclr    #data,*dir
  3452.  
  3453.  
  3454.         AS68HC08 ASSEMBLER                                      PAGE E-3
  3455.         68HC08 INSTRUCTION SET
  3456.  
  3457.  
  3458.         E.2.3  Branch Instructions 
  3459.  
  3460.                 bra     label           brn     label
  3461.                 bhi     label           bls     label
  3462.                 bcc     label           bcs     label
  3463.                 bne     label           beq     label
  3464.                 bhcc    label           bhcs    label
  3465.                 bpl     label           bmi     label
  3466.                 bmc     label           bms     label
  3467.                 bil     label           bih     label
  3468.                 bsr     label           bge     label
  3469.                 blt     label           bgt     label
  3470.                 ble     label
  3471.  
  3472.  
  3473.         E.2.4  Complex Branch Instructions 
  3474.  
  3475.                 cbeqa   [],label
  3476.                 cbeqx   [],label
  3477.                 cbeq    [],label
  3478.                 dbnza   label
  3479.                 dbnzx   label
  3480.                 dbnz    [],label
  3481.  
  3482.  
  3483.         AS68HC08 ASSEMBLER                                      PAGE E-4
  3484.         68HC08 INSTRUCTION SET
  3485.  
  3486.  
  3487.         E.2.5  Read-Modify-Write Instructions 
  3488.  
  3489.                 nega            negx
  3490.                 neg     []
  3491.         
  3492.                 coma            comx
  3493.                 com     []
  3494.         
  3495.                 lsra            lsrx
  3496.                 lsr     []
  3497.         
  3498.                 rora            rorx
  3499.                 ror     []
  3500.         
  3501.                 asra            asrx
  3502.                 asr     []
  3503.         
  3504.                 asla            aslx
  3505.                 asl     []
  3506.         
  3507.                 lsla            lslx
  3508.                 lsl     []
  3509.         
  3510.                 rola            rolx
  3511.                 rol     []
  3512.         
  3513.                 deca            decx
  3514.                 dec     []
  3515.         
  3516.                 inca            incx
  3517.                 inc     []
  3518.         
  3519.                 tsta            tstx
  3520.                 tst     []
  3521.         
  3522.                 clra            clrx
  3523.                 clr     []      clrh
  3524.         
  3525.                 aix     #data
  3526.         
  3527.                 ais     #data
  3528.  
  3529.  
  3530.         AS68HC08 ASSEMBLER                                      PAGE E-5
  3531.         68HC08 INSTRUCTION SET
  3532.  
  3533.  
  3534.         E.2.6  Register\Memory Instructions 
  3535.  
  3536.                 sub     []              cmp     []
  3537.                 sbc     []              cpx     []
  3538.                 and     []              bit     []
  3539.                 lda     []              sta     []
  3540.                 eor     []              adc     []
  3541.                 ora     []              add     []
  3542.                 ldx     []              stx     []
  3543.  
  3544.  
  3545.         E.2.7  Double Operand Move Instruction 
  3546.  
  3547.                 mov     [],[]
  3548.  
  3549.  
  3550.         E.2.8  16-Bit <H:X> Index Register Instructions 
  3551.  
  3552.                 cphx    []
  3553.                 ldhx    []
  3554.                 sthx    []
  3555.  
  3556.  
  3557.         E.2.9  Jump and Jump to Subroutine Instructions 
  3558.  
  3559.                 jmp     []              jsr     []
  3560.  
  3561.  
  3562.  
  3563.  
  3564.  
  3565.  
  3566.  
  3567.  
  3568.  
  3569.  
  3570.  
  3571.  
  3572.  
  3573.  
  3574.                                    APPENDIX F
  3575.  
  3576.                                 AS6809 ASSEMBLER
  3577.  
  3578.  
  3579.  
  3580.  
  3581.  
  3582.         F.1  6809 REGISTER SET 
  3583.  
  3584.         The following is a list of the 6809 registers used by AS6809:  
  3585.  
  3586.                 a,b     -       8-bit accumulators
  3587.                 d       -       16-bit accumulator <a:b>
  3588.                 x,y     -       index registers
  3589.                 s,u     -       stack pointers
  3590.                 pc      -       program counter
  3591.                 cc      -       condition code
  3592.                 dp      -       direct page
  3593.  
  3594.  
  3595.         F.2  6809 INSTRUCTION SET 
  3596.  
  3597.  
  3598.            The  following  tables  list all 6809 mnemonics recognized by
  3599.         the AS6809 assembler.  The designation [] refers to  a  required
  3600.         addressing  mode  argument.   The  following  list specifies the
  3601.         format for each addressing mode supported by AS6809:  
  3602.  
  3603.                 #data           immediate data
  3604.                                 byte or word data
  3605.         
  3606.                 *dir            direct page addressing
  3607.                                 (see .setdp directive)
  3608.                                 0 <= dir <= 255 
  3609.         
  3610.                 label           branch label
  3611.         
  3612.                 r,r1,r2         registers
  3613.                                 cc,a,b,d,dp,x,y,s,u,pc
  3614.         
  3615.                 ,-x     ,--x    register indexed
  3616.                                 autodecrement
  3617.         
  3618.  
  3619.  
  3620.         AS6809 ASSEMBLER                                        PAGE F-2
  3621.         6809 INSTRUCTION SET
  3622.  
  3623.  
  3624.                 ,x+     ,x++    register indexed
  3625.                                 autoincrement
  3626.         
  3627.                 ,x              register indexed addressing
  3628.                                 zero offset
  3629.         
  3630.                 offset,x        register indexed addressing
  3631.                                    -16 <= offset <= 15    ---  5-bit
  3632.                                   -128 <= offset <= -17   ---  8-bit
  3633.                                     16 <= offset <= 127   ---  8-bit
  3634.                                 -32768 <= offset <= -129  --- 16-bit
  3635.                                    128 <= offset <= 32767 --- 16-bit
  3636.                                 (external definition of offset
  3637.                                  uses 16-bit mode)
  3638.         
  3639.                 a,x             accumulator offset indexed addressing
  3640.         
  3641.                 ext             extended addressing
  3642.         
  3643.                 ext,pc          pc addressing ( pc <- pc + ext )
  3644.         
  3645.                 ext,pcr         pc relative addressing
  3646.                                 
  3647.                 [,--x]          register indexed indirect
  3648.                                 autodecrement
  3649.         
  3650.                 [,x++]          register indexed indirect
  3651.                                 autoincrement
  3652.         
  3653.                 [,x]            register indexed indirect addressing
  3654.                                 zero offset
  3655.         
  3656.                 [offset,x]      register indexed indirect addressing
  3657.                                   -128 <= offset <= 127   ---  8-bit
  3658.                                 -32768 <= offset <= -129  --- 16-bit
  3659.                                    128 <= offset <= 32767 --- 16-bit
  3660.                                 (external definition of offset
  3661.                                  uses 16-bit mode)
  3662.         
  3663.                 [a,x]           accumulator offset indexed
  3664.                                 indirect addressing
  3665.         
  3666.                 [ext]           extended indirect addressing
  3667.         
  3668.                 [ext,pc]        pc indirect addressing
  3669.                                 ( [pc <- pc + ext] )
  3670.         
  3671.                 [ext,pcr]       pc relative indirect addressing
  3672.  
  3673.         The  terms  data, dir, label, offset, and ext may all be expres-
  3674.         sions.  
  3675.  
  3676.  
  3677.  
  3678.         AS6809 ASSEMBLER                                        PAGE F-3
  3679.         6809 INSTRUCTION SET
  3680.  
  3681.  
  3682.            Note  that  not all addressing modes are valid with every in-
  3683.         struction, refer to the 6809 technical data for valid modes.  
  3684.  
  3685.  
  3686.         F.2.1  Inherent Instructions 
  3687.  
  3688.                 abx             daa
  3689.                 mul             nop
  3690.                 rti             rts
  3691.                 sex             swi
  3692.                 swi1            swi2
  3693.                 swi3            sync
  3694.  
  3695.  
  3696.         F.2.2  Short Branch Instructions 
  3697.  
  3698.                 bcc     label           bcs     label
  3699.                 beq     label           bge     label
  3700.                 bgt     label           bhi     label
  3701.                 bhis    label           bhs     label
  3702.                 ble     label           blo     label
  3703.                 blos    label           bls     label
  3704.                 blt     label           bmi     label
  3705.                 bne     label           bpl     label
  3706.                 bra     label           brn     label
  3707.                 bvc     label           bvs     label
  3708.                 bsr     label
  3709.  
  3710.  
  3711.         F.2.3  Long Branch Instructions 
  3712.  
  3713.                 lbcc    label           lbcs    label
  3714.                 lbeq    label           lbge    label
  3715.                 lbgt    label           lbhi    label
  3716.                 lbhis   label           lbhs    label
  3717.                 lble    label           lblo    label
  3718.                 lblos   label           lbls    label
  3719.                 lblt    label           lbmi    label
  3720.                 lbne    label           lbpl    label
  3721.                 lbra    label           lbrn    label
  3722.                 lbvc    label           lbvs    label
  3723.                 lbsr    label
  3724.  
  3725.  
  3726.         AS6809 ASSEMBLER                                        PAGE F-4
  3727.         6809 INSTRUCTION SET
  3728.  
  3729.  
  3730.         F.2.4  Single Operand Instructions 
  3731.  
  3732.                 asla            aslb
  3733.                 asl     []
  3734.         
  3735.                 asra            asrb
  3736.                 asr     []
  3737.         
  3738.                 clra            clrb
  3739.                 clr     []
  3740.         
  3741.                 coma            comb
  3742.                 com     []
  3743.         
  3744.                 deca            decb
  3745.                 dec     []
  3746.         
  3747.                 inca            incb
  3748.                 inc     []
  3749.         
  3750.                 lsla            lslb
  3751.                 lsl     []
  3752.         
  3753.                 lsra            lsrb
  3754.                 lsr     []
  3755.         
  3756.                 nega            negb
  3757.                 neg     []
  3758.         
  3759.                 rola            rolb
  3760.                 rol     []
  3761.         
  3762.                 rora            rorb
  3763.                 ror     []
  3764.         
  3765.                 tsta            tstb
  3766.                 tst     []
  3767.  
  3768.  
  3769.         AS6809 ASSEMBLER                                        PAGE F-5
  3770.         6809 INSTRUCTION SET
  3771.  
  3772.  
  3773.         F.2.5  Double Operand Instructions 
  3774.  
  3775.                 adca    []              adcb    []
  3776.         
  3777.                 adda    []              addb    []
  3778.         
  3779.                 anda    []              andb    []
  3780.         
  3781.                 bita    []              bitb    []
  3782.         
  3783.                 cmpa    []              cmpb    []
  3784.         
  3785.                 eora    []              eorb    []
  3786.         
  3787.                 lda     []              ldb     []
  3788.         
  3789.                 ora     []              orb     []
  3790.         
  3791.                 sbca    []              sbcb    []
  3792.         
  3793.                 sta     []              stb     []
  3794.         
  3795.                 suba    []              subb    []
  3796.  
  3797.  
  3798.         F.2.6  D-register Instructions 
  3799.  
  3800.                 addd    []              subd    []
  3801.                 cmpd    []              ldd     []
  3802.                 std     []
  3803.  
  3804.  
  3805.         F.2.7  Index/Stack Register Instructions 
  3806.  
  3807.                 cmps    []              cmpu    []
  3808.                 cmpx    []              cmpy    []
  3809.         
  3810.                 lds     []              ldu     []
  3811.                 ldx     []              ldy     []
  3812.         
  3813.                 leas    []              leau    []
  3814.                 leax    []              leay    []
  3815.         
  3816.                 sts     []              stu     []
  3817.                 stx     []              sty     []
  3818.         
  3819.                 pshs    r               pshu    r
  3820.                 puls    r               pulu    r
  3821.  
  3822.  
  3823.         AS6809 ASSEMBLER                                        PAGE F-6
  3824.         6809 INSTRUCTION SET
  3825.  
  3826.  
  3827.         F.2.8  Jump and Jump to Subroutine Instructions 
  3828.  
  3829.                 jmp     []              jsr     []
  3830.  
  3831.  
  3832.         F.2.9  Register - Register Instructions 
  3833.  
  3834.                 exg     r1,r2           tfr     r1,r2
  3835.  
  3836.  
  3837.         F.2.10  Condition Code Register Instructions 
  3838.  
  3839.                 andcc   #data           orcc    #data
  3840.                 cwai    #data
  3841.  
  3842.  
  3843.         F.2.11  6800 Compatibility Instructions 
  3844.  
  3845.                 aba             cba
  3846.                 clc             cli
  3847.                 clv             des
  3848.                 dex             ins
  3849.                 inx
  3850.                 ldaa    []      ldab    []
  3851.                 oraa    []      orab    []
  3852.                 psha            pshb
  3853.                 pula            pulb
  3854.                 sba             sec
  3855.                 sei             sev
  3856.                 staa    []      stab    []
  3857.                 tab             tap
  3858.                 tba             tpa
  3859.                 tsx             txs
  3860.                 wai
  3861.  
  3862.  
  3863.  
  3864.  
  3865.  
  3866.  
  3867.  
  3868.  
  3869.  
  3870.  
  3871.  
  3872.  
  3873.  
  3874.  
  3875.                                    APPENDIX G
  3876.  
  3877.                                 AS6811 ASSEMBLER
  3878.  
  3879.  
  3880.  
  3881.  
  3882.  
  3883.         G.1  6811 REGISTER SET 
  3884.  
  3885.         The following is a list of the 6811 registers used by AS6811:  
  3886.  
  3887.                 a,b     -       8-bit accumulators
  3888.                 d       -       16-bit accumulator <a:b>
  3889.                 x,y     -       index registers
  3890.  
  3891.  
  3892.         G.2  6811 INSTRUCTION SET 
  3893.  
  3894.  
  3895.            The  following  tables  list all 6811 mnemonics recognized by
  3896.         the AS6811 assembler.  The designation [] refers to  a  required
  3897.         addressing  mode  argument.   The  following  list specifies the
  3898.         format for each addressing mode supported by AS6811:  
  3899.  
  3900.                 #data           immediate data
  3901.                                 byte or word data
  3902.         
  3903.                 *dir            direct page addressing
  3904.                                 (see .setdp directive)
  3905.                                 0 <= dir <= 255 
  3906.         
  3907.                 ,x              register indirect addressing
  3908.                                 zero offset
  3909.         
  3910.                 offset,x        register indirect addressing
  3911.                                 0 <= offset <= 255
  3912.         
  3913.                 ext             extended addressing
  3914.         
  3915.                 label           branch label
  3916.  
  3917.         The terms data, dir, offset, and ext may all be expressions.  
  3918.  
  3919.  
  3920.  
  3921.         AS6811 ASSEMBLER                                        PAGE G-2
  3922.         6811 INSTRUCTION SET
  3923.  
  3924.  
  3925.            Note  that  not all addressing modes are valid with every in-
  3926.         struction, refer to the 6811 technical data for valid modes.  
  3927.  
  3928.  
  3929.         G.2.1  Inherent Instructions 
  3930.  
  3931.                 aba             abx
  3932.                 aby             cba
  3933.                 clc             cli
  3934.                 clv             daa
  3935.                 des             dex
  3936.                 dey             fdiv
  3937.                 idiv            ins
  3938.                 inx             iny
  3939.                 mul             nop
  3940.                 rti             rts
  3941.                 sba             sec
  3942.                 sei             sev
  3943.                 stop            swi
  3944.                 tab             tap
  3945.                 tba             tpa
  3946.                 tsx             txs
  3947.                 wai             xgdx
  3948.                 xgdy
  3949.         
  3950.                 psha            pshb
  3951.                 psh a           psh b
  3952.                 pshx            pshy
  3953.                 psh x           psh y
  3954.         
  3955.                 pula            pulb
  3956.                 pul a           pul b
  3957.                 pulx            puly
  3958.                 pul x           pul y
  3959.  
  3960.  
  3961.         G.2.2  Branch Instructions 
  3962.  
  3963.                 bra     label           brn     label
  3964.                 bhi     label           bls     label
  3965.                 bcc     label           bhs     label
  3966.                 bcs     label           blo     label
  3967.                 bne     label           beq     label
  3968.                 bvc     label           bvs     label
  3969.                 bpl     label           bmi     label
  3970.                 bge     label           blt     label
  3971.                 bgt     label           ble     label
  3972.                 bsr     label
  3973.  
  3974.  
  3975.         AS6811 ASSEMBLER                                        PAGE G-3
  3976.         6811 INSTRUCTION SET
  3977.  
  3978.  
  3979.         G.2.3  Single Operand Instructions 
  3980.  
  3981.                 asla            aslb            asld
  3982.                 asl a           asl b           asl d
  3983.                 asl     []
  3984.         
  3985.                 asra            asrb
  3986.                 asr a           asr b
  3987.                 asr     []
  3988.         
  3989.                 clra            clrb
  3990.                 clr a           clr b
  3991.                 clr     label
  3992.         
  3993.                 coma            comb
  3994.                 com a           com b
  3995.                 com     []
  3996.         
  3997.                 deca            decb
  3998.                 dec a           dec b
  3999.                 dec     []
  4000.         
  4001.                 inca            incb
  4002.                 inc a           inc b
  4003.                 inc     []
  4004.         
  4005.                 lsla            lslb            lsld
  4006.                 lsl a           lsl b           lsl d
  4007.                 lsl     []
  4008.         
  4009.                 lsra            lsrb            lsrd
  4010.                 lsr a           lsr b           lsr d
  4011.                 lsr     []
  4012.         
  4013.                 nega            negb
  4014.                 neg a           neg b
  4015.                 neg     []
  4016.         
  4017.                 rola            rolb
  4018.                 rol a           rol b
  4019.                 rol     []
  4020.         
  4021.                 rora            rorb
  4022.                 ror a           ror b
  4023.                 ror     []
  4024.         
  4025.                 tsta            tstb
  4026.                 tst a           tst b
  4027.                 tst     []
  4028.  
  4029.  
  4030.         AS6811 ASSEMBLER                                        PAGE G-4
  4031.         6811 INSTRUCTION SET
  4032.  
  4033.  
  4034.         G.2.4  Double Operand Instructions 
  4035.  
  4036.                 adca    []              adcb    []
  4037.                 adc a   []              adc b   []
  4038.         
  4039.                 adda    []      addb    []      addd    []
  4040.                 add a   []      add b   []      add d   []
  4041.         
  4042.                 anda    []              andb    []
  4043.                 and a   []              and b   []
  4044.         
  4045.                 bita    []              bitb    []
  4046.                 bit a   []              bit b   []
  4047.         
  4048.                 cmpa    []              cmpb    []
  4049.                 cmp a   []              cmp b   []
  4050.         
  4051.                 eora    []              eorb    []
  4052.                 eor a   []              eor b   []
  4053.         
  4054.                 ldaa    []              ldab    []
  4055.                 lda a   []              lda b   []
  4056.         
  4057.                 oraa    []              orab    []
  4058.                 ora a   []              ora b   []
  4059.         
  4060.                 sbca    []              sbcb    []
  4061.                 sbc a   []              sbc b   []
  4062.         
  4063.                 staa    []              stab    []
  4064.                 sta a   []              sta b   []
  4065.         
  4066.                 suba    []      subb    []      subd    []
  4067.                 sub a   []      sub b   []      sub d   []
  4068.  
  4069.  
  4070.         G.2.5  Bit Manupulation Instructions 
  4071.  
  4072.                 bclr    [],#data
  4073.                 bset    [],#data
  4074.         
  4075.                 brclr   [],#data,label
  4076.                 brset   [],#data,label
  4077.  
  4078.  
  4079.  
  4080.  
  4081.         AS6811 ASSEMBLER                                        PAGE G-5
  4082.         6811 INSTRUCTION SET
  4083.  
  4084.  
  4085.         G.2.6  Jump and Jump to Subroutine Instructions 
  4086.  
  4087.                 jmp     []              jsr     []
  4088.  
  4089.  
  4090.         G.2.7  Long Register Instructions 
  4091.  
  4092.                 cpx     []              cpy     []
  4093.         
  4094.                 ldd     []              lds     []
  4095.                 ldx     []              ldy     []
  4096.         
  4097.                 std     []              sts     []
  4098.                 stx     []              sty     []
  4099.  
  4100.  
  4101.  
  4102.  
  4103.  
  4104.  
  4105.  
  4106.  
  4107.  
  4108.  
  4109.  
  4110.  
  4111.  
  4112.  
  4113.                                    APPENDIX H
  4114.  
  4115.                                 AS6816 ASSEMBLER
  4116.  
  4117.  
  4118.  
  4119.  
  4120.  
  4121.         H.1  6816 REGISTER SET 
  4122.  
  4123.         The following is a list of the 6816 registers used by AS6816:  
  4124.  
  4125.                 a,b     -       8-bit accumulators
  4126.                 d       -       16-bit accumulator <a:b>
  4127.                 e       -       16-bit accumulator
  4128.                 x,y,z   -       index registers
  4129.                 k       -       address extension register
  4130.                 s       -       stack pointer
  4131.                 ccr     -       condition code
  4132.  
  4133.  
  4134.         H.2  6816 INSTRUCTION SET 
  4135.  
  4136.  
  4137.            The  following  tables  list all 6816 mnemonics recognized by
  4138.         the AS6816 assembler.  The designation [] refers to  a  required
  4139.         addressing  mode  argument.   The  following  list specifies the
  4140.         format for each addressing mode supported by AS6816:  
  4141.  
  4142.                 #data           immediate data
  4143.                                 byte or word data
  4144.         
  4145.                 #xo,#yo         local immediate data (mac / rmac)
  4146.         
  4147.                 label           branch label
  4148.         
  4149.                 r               register
  4150.                                 ccr,a,b,d,e,x,y,z,s
  4151.         
  4152.                 ,x              zero offset register indexed addressing
  4153.                 ,x8
  4154.                 ,x16
  4155.         
  4156.                 offset,x        register indexed addressing
  4157.  
  4158.  
  4159.         AS6816 ASSEMBLER                                        PAGE H-2
  4160.         6816 INSTRUCTION SET
  4161.  
  4162.  
  4163.                                      0 <= offset <= 255   ---  8-bit
  4164.                                 -32768 <= offset <= -1    --- 16-bit
  4165.                                    256 <= offset <= 32767 --- 16-bit
  4166.                                 (external definition of offset
  4167.                                  uses 16-bit mode)
  4168.         
  4169.                 offset,x8       unsigned 8-bit offset indexed addressing
  4170.                 offset,x16      signed 16-bit offset indexed addressing
  4171.         
  4172.                 e,x             accumulator offset indexed addressing
  4173.         
  4174.                 ext             extended addressing
  4175.         
  4176.                 bank            64K bank number (jmp / jsr)
  4177.  
  4178.         The  terms data, label, offset, bank, and ext may all be expres-
  4179.         sions.  
  4180.  
  4181.            Note  that  not all addressing modes are valid with every in-
  4182.         struction, refer to the 6816 technical data for valid modes.  
  4183.  
  4184.  
  4185.         H.2.1  Inherent Instructions 
  4186.  
  4187.                 aba             abx             aby             abz
  4188.                 ace             aced            ade             adx
  4189.                 ady             adz             aex             aey
  4190.                 aez             bgnd            cba             daa
  4191.                 ediv            edivs           emul            emuls
  4192.                 fdiv            fmuls           idiv            ldhi
  4193.                 lpstop          mul             nop             psha
  4194.                 pshb            pshmac          pula            pulb
  4195.                 pulmac          rtr             rts             sba
  4196.                 sde             sted            swi             sxt
  4197.                 tab             tap             tba             tbek
  4198.                 tbsk            tbxk            tbyk            tbzk
  4199.                 tde             tdmsk           tdp             ted
  4200.                 tedm            tekb            tem             tmer
  4201.                 tmet            tmxed           tpa             tpd
  4202.                 tskb            tsx             tsy             tsz
  4203.                 txkb            txs             txy             txz
  4204.                 tykb            tys             tyx             tyz
  4205.                 tzkb            tzs             tzx             tzy
  4206.                 wai             xgab            xgde            xgdx
  4207.                 xgdy            xgdz            xgex            xgey
  4208.                 xgez
  4209.  
  4210.  
  4211.         AS6816 ASSEMBLER                                        PAGE H-3
  4212.         6816 INSTRUCTION SET
  4213.  
  4214.  
  4215.         H.2.2  Push/Pull Multiple Register Instructions 
  4216.  
  4217.                 pshm    r,...           pulm    r,...
  4218.  
  4219.  
  4220.         H.2.3  Short Branch Instructions 
  4221.  
  4222.                 bcc     label           bcs     label
  4223.                 beq     label           bge     label
  4224.                 bgt     label           bhi     label
  4225.                 bhis    label           bhs     label
  4226.                 ble     label           blo     label
  4227.                 blos    label           bls     label
  4228.                 blt     label           bmi     label
  4229.                 bne     label           bpl     label
  4230.                 bra     label           brn     label
  4231.                 bvc     label           bvs     label
  4232.                 bsr     label
  4233.  
  4234.  
  4235.         H.2.4  Long Branch Instructions 
  4236.  
  4237.                 lbcc    label           lbcs    label
  4238.                 lbeq    label           lbge    label
  4239.                 lbgt    label           lbhi    label
  4240.                 lbhis   label           lbhs    label
  4241.                 lble    label           lblo    label
  4242.                 lblos   label           lbls    label
  4243.                 lblt    label           lbmi    label
  4244.                 lbne    label           lbpl    label
  4245.                 lbra    label           lbrn    label
  4246.                 lbvc    label           lbvs    label
  4247.                 lbsr    label
  4248.  
  4249.  
  4250.         H.2.5  Bit Manipulation Instructions 
  4251.  
  4252.                 bclr    [],#data
  4253.                 bset    [],#data
  4254.         
  4255.                 brclr   [],#data,label
  4256.                 brset   [],#data,label
  4257.  
  4258.  
  4259.         AS6816 ASSEMBLER                                        PAGE H-4
  4260.         6816 INSTRUCTION SET
  4261.  
  4262.  
  4263.         H.2.6  Single Operand Instructions 
  4264.  
  4265.                 asla            aslb            asld            asle
  4266.                 asl     []      aslw    []                      aslm
  4267.         
  4268.                 asra            asrb            asrd            asre
  4269.                 asr     []      asrw    []                      asrm
  4270.         
  4271.                 clra            clrb            clrd            clre
  4272.                 clr     []      clrw    []                      clrm
  4273.         
  4274.                 coma            comb            comd            come
  4275.                 com     []      comw    []
  4276.         
  4277.                 deca            decb
  4278.                 dec     []      decw    []
  4279.         
  4280.                 inca            incb
  4281.                 inc     []      incw    []
  4282.         
  4283.                 lsla            lslb            lsld            lsle
  4284.                 lsl     []      lslw    []                      lslm
  4285.         
  4286.                 lsra            lsrb            lsrd            lsre
  4287.                 lsr     []      lsrw    []
  4288.         
  4289.                 nega            negb            negd            nege
  4290.                 neg     []      negw    []
  4291.         
  4292.                 rola            rolb            rold            role
  4293.                 rol     []      rolw    []
  4294.         
  4295.                 rora            rorb            rord            rore
  4296.                 ror     []      rorw    []
  4297.         
  4298.                 tsta            tstb            tsta            tste
  4299.                 tst     []      tstw    []
  4300.  
  4301.  
  4302.         AS6816 ASSEMBLER                                        PAGE H-5
  4303.         6816 INSTRUCTION SET
  4304.  
  4305.  
  4306.         H.2.7  Double Operand Instructions 
  4307.  
  4308.                 adca    []      adcb    []      adcd    []      adce
  4309.                 []
  4310.         
  4311.                 adda    []      addb    []      addd    []      adde
  4312.                 []
  4313.         
  4314.                 anda    []      andb    []      andd    []      ande
  4315.                 []
  4316.         
  4317.                 bita    []      bitb    []
  4318.         
  4319.                 cmpa    []      cmpb    []      cpd     []      cpe
  4320.                 []
  4321.         
  4322.                 eora    []      eorb    []      eord    []      eore
  4323.                 []
  4324.         
  4325.                 ldaa    []      ldab    []      ldd     []      lde
  4326.                 []
  4327.         
  4328.                 oraa    []      orab    []      ord     []      ore
  4329.                 []
  4330.         
  4331.                 sbca    []      sbcb    []      sbcd    []      sbce
  4332.                 []
  4333.         
  4334.                 staa    []      stab    []      std     []      ste
  4335.                 []
  4336.         
  4337.                 suba    []      subb    []      subd    []      sube
  4338.                 []
  4339.  
  4340.  
  4341.         H.2.8  Index/Stack Register Instructions 
  4342.  
  4343.                 cps     []              cpx     []
  4344.                 cpy     []              cpz     []
  4345.         
  4346.                 lds     []              ldx     []
  4347.                 ldy     []              ldz     []
  4348.         
  4349.                 sts     []              stx     []
  4350.                 sty     []              stz     []
  4351.  
  4352.  
  4353.         AS6816 ASSEMBLER                                        PAGE H-6
  4354.         6816 INSTRUCTION SET
  4355.  
  4356.  
  4357.         H.2.9  Jump and Jump to Subroutine Instructions 
  4358.  
  4359.                 jmp     bank,[]         jsr     bank,[]
  4360.  
  4361.  
  4362.         H.2.10  Condition Code Register Instructions 
  4363.  
  4364.                 andp    #data           orp     #data
  4365.  
  4366.  
  4367.         H.2.11  Multiply and Accumulate Instructions 
  4368.  
  4369.                 mac     #data           rmac    #data
  4370.                 mac     #xo,#yo         rmac    #xo,#yo
  4371.  
  4372.  
  4373.  
  4374.  
  4375.  
  4376.  
  4377.  
  4378.  
  4379.  
  4380.  
  4381.  
  4382.  
  4383.  
  4384.  
  4385.                                    APPENDIX I
  4386.  
  4387.                                 AS8085 ASSEMBLER
  4388.  
  4389.  
  4390.  
  4391.  
  4392.  
  4393.         I.1  8085 REGISTER SET 
  4394.  
  4395.         The  following  is  a  list  of  the 8080/8085 registers used by
  4396.         AS8085:  
  4397.  
  4398.                 a,b,c,d,e,h,l   -       8-bit accumulators
  4399.                 m               -       memory through (hl)
  4400.                 sp              -       stack pointer
  4401.                 psw             -       status word
  4402.  
  4403.  
  4404.         I.2  8085 INSTRUCTION SET 
  4405.  
  4406.  
  4407.            The  following tables list all 8080/8085 mnemonics recognized
  4408.         by the AS8085  assembler.   The  following  list  specifies  the
  4409.         format for each addressing mode supported by AS8085:  
  4410.  
  4411.                 #data           immediate data
  4412.                                 byte or word data
  4413.         
  4414.                 r,r1,r2         register or register pair
  4415.                                 psw,a,b,c,d,e,h,l
  4416.                                 bc,de,hl,sp,pc
  4417.         
  4418.                 m               memory address using (hl)
  4419.         
  4420.                 addr            direct memory addressing
  4421.         
  4422.                 label           call or jump label
  4423.  
  4424.         The terms data, m, addr, and label may be expressions.  
  4425.  
  4426.            Note  that  not all addressing modes are valid with every in-
  4427.         struction, refer to  the  8080/8085  technical  data  for  valid
  4428.         modes.  
  4429.  
  4430.  
  4431.         AS8085 ASSEMBLER                                        PAGE I-2
  4432.         8085 INSTRUCTION SET
  4433.  
  4434.  
  4435.         I.2.1  Inherent Instructions 
  4436.  
  4437.                 cma             cmc
  4438.                 daa             di
  4439.                 ei              hlt
  4440.                 nop             pchl
  4441.                 ral             rar
  4442.                 ret             rim
  4443.                 rrc             rlc
  4444.                 sim             sphl
  4445.                 stc             xchg
  4446.                 xthl
  4447.  
  4448.  
  4449.         I.2.2  Register/Memory/Immediate Instructions 
  4450.  
  4451.                 adc     r       adc     m       aci     #data
  4452.                 add     r       add     m       adi     #data
  4453.                 ana     r       ana     m       ani     #data
  4454.                 cmp     r       cmp     m       cpi     #data
  4455.                 ora     r       ora     m       ori     #data
  4456.                 sbb     r       sbb     m       sbi     #data
  4457.                 sub     r       sub     m       sui     #data
  4458.                 xra     r       xra     m       xri     #data
  4459.  
  4460.  
  4461.         I.2.3  Call and Return Instructions 
  4462.  
  4463.                 cc      label           rc
  4464.                 cm      label           rm
  4465.                 cnc     label           rnc
  4466.                 cnz     label           rnz
  4467.                 cp      label           rp
  4468.                 cpe     label           rpe
  4469.                 cpo     label           rpo
  4470.                 cz      label           rz
  4471.                 call    label
  4472.  
  4473.  
  4474.         I.2.4  Jump Instructions 
  4475.  
  4476.                 jc      label
  4477.                 jm      label
  4478.                 jnc     label
  4479.                 jnz     label
  4480.                 jp      label
  4481.                 jpe     label
  4482.                 jpo     label
  4483.                 jz      label
  4484.                 jmp     label
  4485.  
  4486.  
  4487.         AS8085 ASSEMBLER                                        PAGE I-3
  4488.         8085 INSTRUCTION SET
  4489.  
  4490.  
  4491.         I.2.5  Input/Output/Reset Instructions 
  4492.  
  4493.                 in      data
  4494.                 out     data
  4495.                 rst     data
  4496.  
  4497.  
  4498.         I.2.6  Move Instructions 
  4499.  
  4500.                 mov     r1,r2
  4501.                 mov     r,m
  4502.                 mov     m,r
  4503.         
  4504.                 mvi     r,#data
  4505.                 mvi     m,#data
  4506.  
  4507.  
  4508.         I.2.7  Other Instructions 
  4509.  
  4510.                 dcr     r               dcr     m
  4511.                 inr     r               inr     m
  4512.         
  4513.                 dad     r               dcx     r
  4514.                 inx     r               ldax    r
  4515.                 pop     r               push    r
  4516.                 stax    r
  4517.         
  4518.                 lda     addr            lhld    addr
  4519.                 shld    addr            sta     addr
  4520.         
  4521.                 lxi     r,#data
  4522.  
  4523.  
  4524.  
  4525.  
  4526.  
  4527.  
  4528.  
  4529.  
  4530.  
  4531.  
  4532.  
  4533.  
  4534.  
  4535.  
  4536.                                    APPENDIX J
  4537.  
  4538.                                  ASZ80 ASSEMBLER
  4539.  
  4540.  
  4541.  
  4542.  
  4543.  
  4544.         J.1  .hd64 DIRECTIVE 
  4545.  
  4546.         Format:  
  4547.  
  4548.                 .hd64 
  4549.  
  4550.         The  .hd64  directive enables processing of the HD64180 specific
  4551.         mnemonics not included in  the  Z80  instruction  set.   HD64180
  4552.         mnemonics  encountered  without  the  .hd64  directive  will  be
  4553.         flagged with an 'o' error.  
  4554.  
  4555.  
  4556.         J.2  Z80 REGISTER SET AND CONDITIONS 
  4557.  
  4558.  
  4559.            The following is a complete list of register designations and
  4560.         condition mnemonics:  
  4561.  
  4562.                 byte registers  -       a,b,c,d,e,h,l,i,r
  4563.                 register pairs  -       af,af',bc,de,hl
  4564.                 word registers  -       pc,sp,ix,iy
  4565.         
  4566.                 C -     carry bit set
  4567.                 M -     sign bit set
  4568.                 NC -    carry bit clear
  4569.                 NZ -    zero bit clear
  4570.                 P -     sign bit clear
  4571.                 PE -    parity even
  4572.                 PO -    parity odd
  4573.                 Z -     zero bit set
  4574.  
  4575.  
  4576.  
  4577.  
  4578.         ASZ80 ASSEMBLER                                         PAGE J-2
  4579.         Z80 INSTRUCTION SET
  4580.  
  4581.  
  4582.         J.3  Z80 INSTRUCTION SET 
  4583.  
  4584.  
  4585.            The  following  tables  list all Z80/HD64180 mnemonics recog-
  4586.         nized by the ASZ80 assembler.  The designation []  refers  to  a
  4587.         required addressing mode argument.  The following list specifies
  4588.         the format for each addressing mode supported by ASZ80:  
  4589.  
  4590.                 #data           immediate data
  4591.                                 byte or word data
  4592.         
  4593.                 n               byte value
  4594.         
  4595.                 rg              a byte register
  4596.                                 a,b,c,d,e,h,l
  4597.         
  4598.                 rp              a register pair
  4599.                                 bc,de,hl
  4600.         
  4601.                 (hl)            implied addressing or
  4602.                                 register indirect addressing
  4603.         
  4604.                 (label)         direct addressing
  4605.         
  4606.                 offset(ix)      indexed addressing with
  4607.                                 an offset
  4608.         
  4609.                 label           call/jmp/jr label
  4610.  
  4611.         The  terms  data,  dir,  offset, and ext may all be expressions.
  4612.         The terms dir and offset are not allowed to be  external  refer-
  4613.         ences.  
  4614.  
  4615.            Note  that  not all addressing modes are valid with every in-
  4616.         struction, refer to the Z80/HD64180  technical  data  for  valid
  4617.         modes.  
  4618.  
  4619.  
  4620.         ASZ80 ASSEMBLER                                         PAGE J-3
  4621.         Z80 INSTRUCTION SET
  4622.  
  4623.  
  4624.         J.3.1  Inherent Instructions 
  4625.  
  4626.                 ccf             cpd
  4627.                 cpdr            cpi
  4628.                 cpir            cpl
  4629.                 daa             di
  4630.                 ei              exx
  4631.                 halt            neg
  4632.                 nop             reti
  4633.                 retn            rla
  4634.                 rlca            rld
  4635.                 rra             rrca
  4636.                 rrd             scf
  4637.  
  4638.  
  4639.         J.3.2  Implicit Operand Instructions 
  4640.  
  4641.                 adc     a,[]            adc     []
  4642.                 add     a,[]            add     []
  4643.                 and     a,[]            and     []
  4644.                 cp      a,[]            cp      []
  4645.                 dec     a,[]            dec     []
  4646.                 inc     a,[]            inc     []
  4647.                 or      a,[]            or      []
  4648.                 rl      a,[]            rl      []
  4649.                 rlc     a,[]            rlc     []
  4650.                 rr      a,[]            rr      []
  4651.                 rrc     a,[]            rrc     []
  4652.                 sbc     a,[]            sbc     []
  4653.                 sla     a,[]            sla     []
  4654.                 sra     a,[]            sra     []
  4655.                 srl     a,[]            srl     []
  4656.                 sub     a,[]            sub     []
  4657.                 xor     a,[]            xor     []
  4658.  
  4659.  
  4660.         ASZ80 ASSEMBLER                                         PAGE J-4
  4661.         Z80 INSTRUCTION SET
  4662.  
  4663.  
  4664.         J.3.3  Load Instruction 
  4665.  
  4666.                 ld      rg,[]           ld      [],rg
  4667.                 ld      (bc),a          ld      a,(bc)
  4668.                 ld      (de),a          ld      a,(de)
  4669.                 ld      (label),a       ld      a,(label)
  4670.                 ld      (label),rp      ld      rp,(label)
  4671.                 ld      i,a             ld      r,a
  4672.                 ld      a,i             ld      a,r
  4673.                 ld      sp,hl           ld      sp,ix
  4674.                 ld      sp,iy           ld      rp,#data
  4675.         
  4676.                 ldd                     lddr
  4677.                 ldi                     ldir
  4678.  
  4679.  
  4680.         J.3.4  Call/Return Instructions 
  4681.  
  4682.                 call    C,label         ret     C
  4683.                 call    M,label         ret     M
  4684.                 call    NC,label        ret     NC
  4685.                 call    NZ,label        ret     NZ
  4686.                 call    P,label         ret     P
  4687.                 call    PE,label        ret     PE
  4688.                 call    PO,label        ret     PO
  4689.                 call    Z,label         ret     Z
  4690.                 call    label           ret
  4691.  
  4692.  
  4693.         J.3.5  Jump and Jump to Subroutine Instructions 
  4694.  
  4695.                 jp      C,label         jp      M,label
  4696.                 jp      NC,label        jp      NZ,label
  4697.                 jp      P,label         jp      PE,label
  4698.                 jp      PO,label        jp      Z,label
  4699.         
  4700.                 jp      (hl)            jp      (ix)
  4701.                 jp      (iy)            jp      label
  4702.         
  4703.                 djnz    label
  4704.         
  4705.                 jr      C,label         jr      NC,label
  4706.                 jr      NZ,label        jr      Z,label
  4707.                 jr      label
  4708.  
  4709.  
  4710.         ASZ80 ASSEMBLER                                         PAGE J-5
  4711.         Z80 INSTRUCTION SET
  4712.  
  4713.  
  4714.         J.3.6  Bit Manipulation Instructions 
  4715.  
  4716.                 bit     n,[]
  4717.                 res     n,[]
  4718.                 set     n,[]
  4719.  
  4720.  
  4721.         J.3.7  Interrupt Mode and Reset Instructions 
  4722.  
  4723.                 im      n
  4724.                 im      n
  4725.                 im      n
  4726.                 rst     n
  4727.  
  4728.  
  4729.         J.3.8  Input and Output Instructions 
  4730.  
  4731.                 in      a,(n)           in      rg,(c)
  4732.                 ind                     indr
  4733.                 ini                     inir
  4734.         
  4735.                 out     (n),a           out     (c),rg
  4736.                 outd                    otdr
  4737.                 outi                    otir
  4738.  
  4739.  
  4740.         J.3.9  Register Pair Instructions 
  4741.  
  4742.                 add     hl,rp           add     ix,rp
  4743.                 add     iy,rp
  4744.         
  4745.                 adc     hl,rp           sbc     hl,rp
  4746.         
  4747.                 ex      (sp),hl         ex      (sp),ix
  4748.                 ex      (sp),iy
  4749.                 ex      de,hl
  4750.                 ex      af,af'
  4751.         
  4752.                 push    rp              pop     rp
  4753.  
  4754.  
  4755.         ASZ80 ASSEMBLER                                         PAGE J-6
  4756.         Z80 INSTRUCTION SET
  4757.  
  4758.  
  4759.         J.3.10  HD64180 Specific Instructions 
  4760.  
  4761.                 in0     rg,(n)
  4762.                 out0    (n),rg
  4763.         
  4764.                 otdm                    otdmr
  4765.                 otim                    otimr
  4766.         
  4767.                 mlt     bc              mlt     de
  4768.                 mlt     hl              mlt     sp
  4769.         
  4770.                 slp
  4771.         
  4772.                 tst     a
  4773.                 tstio   #data
  4774.